Debugging DotNetNuke modules

13. March 2010 21:55

There have been some questions about how to debug when developing DotNetNuke modules. If you have followed my module development tutorial series you know you can’t just start a debugging session for the module project.
To debug your module code you have to attach the debugger to the process actually running the code. Since the development website is running on your local webserver, that process is the IIS worker process.

Before you start debugging, make sure the module is installed on the development website and that the control you want to debug is added to a page on the website (so the code we want to debug is run when we enter that page).
Open up the development website in your browser to make sure the webserver worker process is running. Open up your module project in Visual Studio.
In the Debug menu, select Attach to process…
In the Attach to process dialog, select aspnet_wp.exe from the Available processes list and click the Attach button.
The screenshot below is from an XP machine. If you use Vista or Win 7, the name of the worker process is w3wp.exe.

Attach to process dialog

Now execution will stop at any breakpoints in your code, just as usual.

Try it out by setting a breakpoint in the Page_Load method in ViewProducts.ascx.cs and surf to the page where you added the module.

When you are done debugging, go into the Debug menu again and select Stop Debugging.

Tags: , ,

DotNetNuke | Modules

Comments

6/13/2010 12:41:28 AM #

Ken Ingram

Hi, I've been going through your (VB) tutorials for DNN 5 Module Development and finding it very enjoyable and informative. It was perfect for me as I am using VS 10 and VB.net (I do this for my day job too).  I'm having a couple of problems with the Products module and wanted to know you saw something obvious to help me out. One thing is that no data is being saved to the database.  The tables and stored procedures are all there and my connection strings in web.config use the "sa" user so it should not be a permissions problem, but when I select from the SipidCode_Products table (after entering a product online from the instance of the module), no rows are returned.  

Secondly, when I tried to go into debug using the Products project and attach to process w3wp.exe and set a breakpoint in the ViewProducts.ascx.vb (or EditProducts.ascx.vb), VS tells me that "The breakpoint will not currently be hit. No symbols have been loaded for this document." I did build in debug mode and the PDB file was generated and is in the bin folder of the web site.  Does it need to be somewhere in the Desktop Modules\Products or is there some other setting I am missing.  

Thanks in advance and I really do appreciate the help.

Ken Ingram

Ken Ingram United States |

6/13/2010 1:12:58 AM #

Ken Ingram

Nevermind on my previous help requests. Found both of my problems. Was not entering a Product name so it was not storing (only entered a description...duh). The other problem was that I had to have VS 2010 "always show solution" set to see the Configuration Manager.  It was in Release so changing to Debug allowed debugging from attach process.

Keep up the good work and thank you again for the tutorials.

Ken Ingram

Ken Ingram United States |

6/13/2010 10:23:55 AM #

Johan

Those tiny details are the worst, aren't they? ;)
Now when you're back on track, create some great modules!
Good luck,
/Johan

Johan Sweden |

6/13/2010 3:42:18 PM #

Ken Ingram

Will do.  Thank you again for a concise, informative tutorial from which I (and many others I am sure) will build a foundation of knowledge to build great modules on.

Ken Ingram

Ken Ingram United States |

7/15/2010 9:59:31 PM #

myoa

Thank you so much! It helped a lot!!

Just a quick note about the debugging part. "Attach to process..." was in the Tools menu in my VS2008. Then when I attached the process, the breakpoints were all having a "the breakpoint will not currently be hit" message. I had to go to Debug menu - Window - Module. Then right-click on my module.dll and choose Load Symbols from Microsoft Symbols Library. And then it worked like a charm,

Thanks again!

myoa Canada |

9/5/2012 8:30:13 AM #

BN

It was really helpful to me.
Thanks.

BN Iran |

Comments are closed

About the addict

Johan Seppäläinen lives in Uppsala, Sweden. He spends most of his days working as a systems architect/developer, specialized in solutions built on Microsoft platforms.
Occasionally there is time for some recreational coding, when he pursues optimal solutions and code zen, mainly in C#. When he is not writing in this blog, that is.