Pitfalls in Visual Studio Add-in programming Investigating a Silverlight crash in Firefox

Firefox Debug Helper (Visual Studio Add-in)

Published on Tuesday, September 14, 2010 8:52:00 PM UTC in Programming & Tools

A newer version of this tool can be found here.

Ever since the release of Firefox 3.6.4 (and its new plug-in isolation feature), a smooth debugging experience for Silverlight developers who use that browser went away. The problem is that Visual Studio attaches correctly to the Firefox process; however, all Silverlight applications now run in a separate process called 'plugin-container.exe', and so the debugger is not able to find them. You're now left with three options:

  1. Either attach to the correct process manually each time you want to debug a Silverlight application or
  2. Disable the feature altogether or
  3. Switch to a different browser

Option 1 is pretty tedious work if you have to do it over and over again, all day long. Option 2 on the other hand is a dangerous thing to do, because disabling that feature is not straight forward, which means that you're now testing your application in a different environment than 99,9% of all your users. Unfortunately, Silverlight behaves differently with or without that option enabled in some scenarios, so turning that feature off is not recommended - unless you want to risk that serious bugs slip through undiscovered and in the worst case surface only at your users. Finally, Option 3 was not an option for me out of personal taste.

Manually attaching to the plugin-container process

(Manually attaching to the plugin-container process of Firefox)

So what now? The idea was to write a simple Visual Studio add-in that does nothing else but attach to that process automatically when you start a debugging session. That turned out to be harder than I thought. If you're interested in some of the details, I'll discuss them in this follow-up post. If you're only interested in the add-in itself, you can download it directly here.

Update 2010-10-02: Two packages are available. If you only are interested in using the add-in, download the VSI package. A simple double-click launches the Visual Studio Content Installer and leads you through the process of installing the add-in. The zip archive contains the source code, for those of you who are interested in the implementation details.

[The old download links have been removed. A new version can be found here.]

Disclaimer:This add-in comes as-is, without warranty of any kind. You use it at your own risk, and I'm not liable for any damages caused by the use of this add-in. I only tested this software in my own development environment, which is Visual Studio 2010 and Windows 7 64-bit (both English versions).

Now that the official part is done, here is a short description of what the add-in does: when you start a debugging session, it first looks if your solution contains one or more Silverlight projects. If it does, it checks whether Visual Studio attaches to the Firefox process. Then it searches through the local processes for the plugin container process of Firefox and picks the right one if there is more than one by determining which one has loaded the Silverlight runtime (there may be additional of these processes for Flash etc.). If the process is found, it attaches the Silverlight debug engine to it.

The add-in outputs messages to the debug pane of Visual Studio's output window. If anything goes wrong, that should be the place to look for. You can also disable the plug-in in Visual Studio's Add-in Manager. If you want to remove it completely, simply delete the .dll and .AddIn files from the folder MyDocuments/Visual Studio 2010/Addins. On the next startup, Visual Studio will notify you that the plugin could not be found and offers to remove it from the plug-ins list.

Visual Studio's add-in manager

Happy debugging! :)

Tags: Firefox · Silverlight · Visual Studio Add-in