VSStub

Background

Developing add-ins can be a bit of a hassle, especially if the add-in is currently used by Visual Studio. How do you test/debug it? Well, after you compile it you have to...

  1. Close Visual Studio.
  2. Copy the add-in to the AddIns folder.
  3. Start Visual Studio and load the add-in project.
  4. Realize it has some bug.
  5. Modify and compile it.
  6. Go back to Step 1....

Not only is it cumbersome, if it breaks (as things may do in their development phase) during this process so that Visual Studio can't load it, you obviously can't debug it.

What Does VSStub Do?

VSStub loads an add-in (path to it shall be given as a command-line parameter) and, from the add-in's point of view, behaves pretty much like Visual Studio.

It implements the basic interfaces of the Developer Studio Object model: IApplication, IDebugger, ITextDocument, and so forth.

It is naturally not as sophisticated as Visual Studio itself (for example, it re-uses the same IDocument instance over and over even if the add-in tells it to create a new one), but it gives something for the add-in to interact with. Most of the attributes can be modified through the GUI and you can, of course, tweak it to better suit your needs.

You can call the add-in's commands and fire various events to see how the add-in behaves; for instance, by setting a breakpoint at the add-in's command/event implementation. If you find some bug in the add-in, just fix it, compile, and run...

Typical Usage

In the add-in's project settings:

  1. Set VSStub to be the add-in's executable.
  2. Set the path to the add-in as program arguments.

Set breakpoints or whatever and run it...

About the Source Code

VSStub is an ordinary (if there is such a thing) MFC Dialog application.

Getting the add-in's CLSID is somewhat difficult because there is no way to just ask for it. The CLSID is required as input when calling DllGetClassObject to get the IClassFactory.

VSStub solves this by:

  1. Unregistering the add-in (DllUnregisterServer). This ensures the add-in's CLSID is not in HKEY_CLASSES_ROOT/CLSID.
  2. Checking the time stamp.
  3. Registering the add-in (DllRegisterServer). This should put the CLSID in HKEY_CLASSES_ROOT/CLSID.
  4. Enumerating sub keys in HKEY_CLASSES_ROOT/CLSID, looking for keys where LastWriteTime>=time stamp.
Note: If Visual Studio uses the add-in, the next time Visual Studio starts it will use the add-in that was last registered.

(If anyone knows of a better way to get the CLSID, I'd be glad to hear about it.)



Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • When it comes to desktops – physical or virtual – it's all about the applications. Cloud-hosted virtual desktops are growing fast because you get local data center-class security and 24x7 access with the complete personalization and flexibility of your own desktop. Organizations make five common mistakes when it comes to planning and implementing their application management strategy. This eBook tells you what they are and how to avoid them, and offers real-life case studies on customers who didn't …

  • Hurricane Sandy was one of the most destructive natural disasters that the United States has ever experienced. Read this success story to learn how Datto protected its partners and their customers with proactive business continuity planning, heroic employee efforts, and the right mix of technology and support. With storm surges over 12 feet, winds that exceeded 90 mph, and a diameter spanning more than 900 miles, Sandy resulted in power outages to approximately 7.5 million people, and caused an estimated $50 …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds