Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Does anyone know if there is any known problem with getting VS2010 to hit a breakpoint in a static class constructor on an ASP.NET website running on local IIS?

If I place a breakpoint in the constructor, it is never hit. However, if I place a breakpoint elsewhere in the file, it is hit and the value in the debugger seem to indicate that the static constructor has executed.

Kind wishes, Patrick
Posted

1 solution

A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.

You have no control as to when the static constructor is executed. As a tip, move the control from your constructor to a static Initialize() function.
 
Share this answer
 
Comments
ProEnggSoft 10-Mar-12 9:06am    
Good explanation. I think the statement You have no control as to when the static constructor is executed. is vital. My 5
Uday P.Singh 10-Mar-12 10:23am    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900