Visual Studio Options Pages

Configure visual studio addins

Published on Friday, February 15, 2008

Like many addin developers I create options pages in visual studio to handle configuration of my software.  While extremely simple to create these pages, it is not obvious how they should be configured to load with visual studio.  Additionally, the documentation for creating options pages provided by Microsoft describes in detail how to create options pages, though neglects to describe how to make visual studio recognize your options page control.

Fortunately this is extremly simple to wire up.

<?xml version="1.0" encoding="utf-16" standalone="no"?>
<extensibility xmlns="<a href="http://schemas.microsoft.com/AutomationExtensibility" mce_href="http://schemas.microsoft.com/AutomationExtensibility">http://schemas.microsoft.com/AutomationExtensibility</a>">
  <hostApplication>
    <name>Microsoft Visual Studio</name>
    <version>9.0</version>
  </hostApplication>
  <hostApplication>
    <name>Microsoft Visual Studio</name>
    <version>8.0</version>
  </hostApplication>
  <addin>
    <friendlyName>.netSavant</friendlyName>
    <description>.netSavant is a powerful code generator for the .net framework and Visual Studio.NET.  For more information please visit <a href="http://www.dotnetsavant.com/" mce_href="http://www.dotnetsavant.com/">http://www.dotnetsavant.com</a> </description>
    <aboutBoxDetails>For more information about .netSavant please visit <a href="http://www.dotnetsavant.com/" mce_href="http://www.dotnetsavant.com/">http://www.dotnetsavant.com</a> </aboutBoxDetails>
    <aboutIconData></aboutIconData>
    <assembly>Path to .netSavant assembly</assembly>
    <fullClassName>DotNetSavant.Connect</fullClassName>
    <loadBehavior>1</loadBehavior>
    <commandPreload>1</commandPreload>
    <commandLineSafe>0</commandLineSafe>
  </addin>
  <toolsOptionsPage>
    <category Name="DotNetSavant">
      <subCategory Name="Adapter Generation">
        <assembly>Path to .netSavant assembly</assembly>
        <fullClassName>DotNetSavant.Controls.AdapterSettingsOptionsPage</fullClassName>
      </subCategory>
    </category>
  </toolsOptionsPage>
</extensibility> 

You'll notice that I added a ToolsOptionPage node under the root Extensibility node of a standard .addin xml file.  Here you can identify hierarchal categories that will be displayed as visual studio options pages.In this example I've added a top level options page called "DotNetSavant" with a sub category named "Adapter Generation".  Similar to the addin node of the base .addin file, both Category and SubCategory nodes can specify a single Assembly and FullClassName node.  Set the assembly nodes' inner text to the path of the assembly where your options pages control exists and then specify the fully qualified name of your options pages class in the FullClassName node and your options pages will load with visual studio.