Can’t debug into a MOSS Webpart

I am doing some work at present where I need to debug into webparts hosted in a MOSS 2007 server. Never an easy set of debugging to get right.

To try to ease the process I wrote a WinForm test application that just calls the webpart method with test parameters so I don’t have to go through all the pages I normally would to get to the feature I need, or manually have to attach the debugger to the Sharepoint web process every time.

I added this WinForm project to the same solution as my Sharepoint webpart, this should have allowed me to debug into the webpart project when the appropriate call was made from the WinForm, but it did not work.

Turned out the problem was the Network Service account did not have rights to the C:\Windows\temp and C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files directories. Once write access was granted the IDE was able to create the temporary classes to allow debugging.