Monday, July 29, 2013

Debug supporting projects within a WinForms solution without having the source code for the solution!

If multiple WinForms apps use common .dlls (projects inside Visual Studio solutions) and you would like to do the "attach to process" trick while running one WinForm app to look into a .dll kept in another project within a different solution where a WinForm project serves as the UI project, you may still do so. Again, this assumes you are not debugging the UI WinForms project, but a common second project. Start by putting the following line of C# in a spot in code you know will get hit in the common-across-two-solutions project:

Thread.Sleep(30000);

 
 

Rebuild the solution. Put a copy of the appropriate .dll in the bin folder of the WinFroms application you are to run. Set a breakpoint to hit back in the project in Visual Studio. Open "Component Services" and drill down to: Console Root > Component Services > Computers > My Computer > COM+ Applications ...select COM+ Applications and then pick "Status" from the "View" menu at the top navigation. This should allow you to see a few columns including "PID" which is vital for this process. Run the WinForms app and wait for a new line item to appear in the list here. Note the PID and then in Visual Studio pick "Attack to Process..." from "Tools" and find the item to attach to*. The ID at Visual Studio will match up to the PID at Component Services.

*check the checkbox for: Show processes for all users

No comments:

Post a Comment