by Andreas

How to debug custom Sharepoint webparts

If you create a test suite for unit testing your custom Sharepoint webpart you might come across the following warning when running your tests:

The following module was built either with optimizations enabled or without debug information

image

You’ll also find that you’re unable to step into the methods while debugging, as if you don’t have access to the source of the assembly.

 

imageThe reason for this is that Sharepoint modules are signed with a Strong Name Key, because they are supposed to be deployed to the GAC. The solution is therefore to ensure that you deploy your web part before running your unit tests, and you’ll find that the warning message disappears and you’ll be able to debug the web part source as well.