Wednesday, July 9, 2008

Attaching To Process

Let's say you just spent a ton of time creating the best .DLL in the world. Now you want to see it run in action but there are errors that you can't seem to track down. The best thing to do is test it out using the 'Attach To Process' in Visual Studio.

Here's how it works ...
Drop the .DLL into the _app_bin folder of your Web Applicaiton. The one I am doing this one in is the '80' folder under C:\Inetpub\wwwroot\wss\VirtualDirectories\80.
Make sure you make the appropiate web.config changes so that your web part or code segment is set up correctly. In the case of this example, please refer to the the WSS Navigation post. I added a line to the area.

I then made a refernce in my MasterPage that used the code.

Load your .DLL project inside Visual Studio. Click Debug -> Attach To Process.

Select the W3WP.exe process. If you are running multiple instances of IE, you will see a few of these. So this may be trail and error. I would recommend closing IE and doing an IISReset to make it easier.

Drop a break point on the line of code that you want to investigate.

Refresh the page and click the action you need to fire it. You are now able to step through the code and see what's causing your issue.

0 comments: