I’m trying to create a method that is called when the application is initialized, except when creating a web application, you can only debug it by attaching it to the IIS process (w3wp.exe).
The problem is that this process is only created after initializing the application, which make it impossible to attach the Visual studio debugger to it before calling that method.
Anyone has a solution for this??
You can use the Cassini web server that is included with Visual Studio. In the Web settings for your project you should select User Visual Studio Development Server. This will allow you to debug your application by pressing F5.
If you really need to debug inside IIS you can force a debugger break in your
Initializemethod by doing a call toDebugger.Break. If you have a debuger installed you will get the option to attach a debugger.If you a have a very unwieldly application that is hard to debug (besides refactoring it into more managable and testable parts) you can instrument your code with logging. This will allow you to troubleshoot your application even in a production environment. .NET has built-in support for logging and there also exists several good open source frameworks that you can use.