Tools for the toolset of add-in developers

When you think about developing add-ins likely you think that the only tools that you need are Visual Studio IDE and its debugger, right? Well, sometimes you will find that your add-in does not appear in the Add-In Manager at all, or it doesn’t load (apparently) or it causes some COM exception when it is loaded. I see those questions frequently in the extensibility forums and I always recommend to add these tools to your debugging toolset:

  • A registry monitor, to spy what VS does when it tries to discover your add-in (if your add-in uses COM and registry-based registration, not XML-based registration).
  • A file monitor, to spy disk activity when you are using XML-based registration (an .Addin file).

I used two separated tools from sysinternals (recently purchased by Microsoft) but the good news is that they are now merged into a new all-in-one monitoring tool named Process Monitor:

http://www.microsoft.com/technet/sysinternals/FileAndDisk/processmonitor.mspx

The Process Monitor also replaces the Process Explorer tool that I was using to monitor which processes are running and which DLLs are loaded (it can be configured to replace the Task Manager of Windows too!)

There are other tools here:

http://www.microsoft.com/technet/sysinternals/default.mspx

There is another invaluable tool named Lutz Roeder’s .NET Reflector (http://www.aisto.com/roeder/dotnet/)  which allows you to disassemble a .NET assembly and generate not only IL code (like ildasm) but also VB.NET or C# code. There are even plug-ins for that tool that save the disassembled code (which is shown on the screen) to a file or to a whole new VS project. This tool is invaluable when you want to know how VS works internally, for the portions that are managed code (VS is still a COM application), which are most of the new portions of VS 2005. You can use it also to see the internals of the designers of the .NET Framework, etc. The first thing to know is where to look. Many assemblies of VS 2005 are in this folder:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies

But others seems to be only in the GAC. Say that you want to know how the Document Outline feature of VS 2005 is implemented internally. It happens that this feature is in this assembly of the GAC (I have been unable to find it elsewhere):

Microsoft.VisualStudio.Windows.Forms.dll

How do you use .NET Reflector to disassemble that assembly (the several “Open” dialogs of the tool don’t show it)? Here is a little trick (it’s a good thing that I am old enough to know MS-DOS):

  • Open a DOS command prompt
  • Type:

SUBST P: C:\Windows\Assembly

and then you can navigate to:

P:\GAC_MSIL\Microsoft.VisualStudio.Windows.Forms\2.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Windows.Forms.dll and the class is Microsoft.VisualStudio.Windows.Forms.DocumentOutline. So you expand it, select a method, right-click “Disassembler” and there it is the code! You can also right-click “Analyzer” to show where a method is called. With this tool you can know how the Property Browser works insternally (quite complicated indeed!) and other portions of VS 2005. Alas, many other portions of VS are unmanaged so there is no X-ray for them (unless you like the native x86 code) 🙂