How to debug IIS7 C# module in VS2010? [Answered]RSS

3 replies

Last post Jan 17, 2013 04:17 AM by rasmusra

  • How to debug IIS7 C# module in VS2010?

    Jun 22, 2010 10:54 AM|john.newman|LINK


    Title pretty much covers it, I've got a C# dll deployed in IIS7.  It is working ok, I can re copy it and see my changes.  Of course, my logic is all messed up and it's not at all doing what I want, so I need to debug.  So far I'm not finding a whole lot of information on how to do this.

    I can mark a break point and use debug > attach to process > (IIS PID), but my break point never gets hit.  How?  Any ideas?


  • Re: How to debug IIS7 C# module in VS2010?

    Jun 22, 2010 01:48 PM|CarlosAg|LINK

    The first thing is make sure you find the right PID, that would be a w3wp.exe that using Task Manager you can add the Command Line and make sure you see the right Application Pool name in there.

    Make sure that you have symbols that match, for that if you are using a Debug version you will find them in the debug, if using retail you might need to enable generate symbols depending on your configuration. Bottom-line you need to find the right .PDB file for your DLL.

    That should make it, just to make sure also disable the "Enable Just My Code" flag in the Tools->Options->Debugging.

  • Re: How to debug IIS7 C# module in VS2010?

    Jun 22, 2010 03:37 PM|john.newman|LINK

     thanks Carlos, I was able to get it to work.  When I tried this the other day, I was attaching to the svchost.exe process that is the IIS service, and not the w3wp.exe that is the app pool.


    So, to clarify for reference in case anyone stumbles upon this thread, to debug iis 7 module:

      1.  build .cs file into .dll

       2.  copy .dll & .pdb to target folder (probably inetpub\wwwroot\bin)

       3.  make sure app pool is started, you have to make one request to it if the w3wp.exe process does not appear.

       4.  Add required entry into web.config to load module  (or globally, whatever you are doing)

       5.  place breakpoint in your .cs file

       6.   Debug > attach to process, show processes in all sessions, find w3wp.exe, attach to Managed (v4.0) code  (and possibly native)

       7.  hit breakpoint and solve your problems the easy way


    thanks again Carlos!  Now that I can inspect, I can figure out WTF is going on with the session being recreated everytime and this child request stuff.   :-)


  • Re: How to debug IIS7 C# module in VS2010?

    Jan 17, 2013 04:17 AM|rasmusra|LINK

    Hi all,

    I have done all this
    - deploy site with debug info
    - attach to the w3wp.exe
    - set the breakpoint in code (in VS proj)
    - debug with mstest

    Code executes on local IIS (in c:\inetpub\wwwroot)  but the breakpoint does not take on the server.

    Any ideas? Site got anonymous + windows auth + ssl

    I can also add that I have IIS7 Express installed. On that one debugging works. I want to switch to IIS7 but want debugging to work before removing the express (since that one works, duh). I found this related thread: