It can be difficult to debug the application_start event due to the fact that it fires only once during the lifetime of the application. Usually, to debug this, you will need to shutdown your application so that the application_start event will fire the next time a request occurs. The easiest way to do this is to recycle IIS.
Once IIS has started back up, you can set a breakpoint in the IDE. Odds are, the IDE will not let you attach to the worker process as there is no managed code running in it or there will be no worker process running.
To get around this, you can make a request to a different application (on the same machine) to put managed code in the worker processed/start the worker process You can then attach to it with your breakpoint set and issue a request.
An easier method will probably be to add a call to System.Diagnostics.Debugger.Break() in the application_start event. This will force the IDE to attach to the process and allow you to step through. You will probably want to remove this before you check in to source control if you have other people working on it as they probably do not need to debug every application start up. The good news is that as long as your are deploying release binaries to production, a call to Debugger.Break will not cause execution to halt.
No comments:
Post a Comment