Recently, I needed to debug into the Sitecore.Kernel.dll. It was pretty straight forward to setup. Here’s how:
Install dotPeek
dotPeek is a free decompiler from the folks over at JetBrains. I used it to look at the Sitecore code when I need to figure out what the proper code patterns should be when I am extending Sitecore.
Add assemblies to the assembly explorer
By default there are some .net classes listed. You can leave them or clear them. I’ve cleared my list and added just the Sitecore.Kernel.dll.
Configure the Symbol server
dotPeek will act as a symbol server for you. First, go to Tools –> Options
Then, with Symbol Server selected on the left, choose which Assemblies you want to generate a (.pdb) file for. The Symbol Server url is listed as well. We’ll need that later.
On that screen, you are instructed on how to add http://localhost:33417 to the Visual Studio Symbol Server.
Start the Symbol Server
In dotPeek, start the Symbol Server. You can do this by either clicking the menu button or going to Tools–>Symbol Server.
Configure Visual Studio
Under Tools–>Options in Visual Studio, find Debugging –> Symbols in the left menu.
- Click the plus sign to add your local symbol server: http://localhost:33417. Make sure the box is checked.
- Provide a path for the SymbolCache
- Choose “Load only specified modules”
- Click the plus sign to add a new dll to load symbols for.
- Manually enter the names of the dlls you want to have access to. Be sure to add the extension. I.E. Sitecore.Kernel.dll and not just Sitecore.Kernel
Under Tools–>Options in Visual Studio, find Debugging
- Find the checkbox for “Enable just my code” and uncheck that. Click “Ok”
Set the breakpoint
Go to Debug–>New Breakpoint–>Function Breakpoint
In the dialog that pops up, you will enter the name of the method you want to break in.
Here is the format for the function: [namspace]+[class name]+[method name]
Example: Sitecore.Shell.Applications.ContentEditor.Link.HandleMessage
This example entry will break whenever a content author clicks a menu option of the general link field, like “insert external link”
Attach Visual Studio to the w3wp.exe process
As you would do if you are debugging your own code, configure VS to attached to the w3wp.exe process.
That’s it. The breakpoint will be hit and you can step into the Sitecore code. Pretty easy!