How to debug into Sitecore dlls

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.

  1. Click the plus sign to add your local symbol server: http://localhost:33417. Make sure the box is checked.
  2. Provide a path for the SymbolCache
  3. Choose “Load only specified modules”
  4. Click the plus sign to add a new dll to load symbols for.
  5. 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

  1. 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”

The breakpoint gets added to the Breakpoints window

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!

About Phil Paris

Hi, my name is Phil Paris and I’m a Sitecore Architect and general Sitecore enthusiast. I’ve been working with Sitecore since 2013. Through this blog I will be sharing Sitecore insights, tips and tricks, best practices and general knowledge with the hopes to further the community at large. Please feel free to reach out to me at any time!

View all posts by Phil Paris →