Troubleshooting Feature Extensions
You can create your own feature extensions, such as custom code analysis rules, database unit test conditions, data generators, refactoring types, build contributors, and deployment contributors. When you install these feature extensions, issues might arise that prevent your extension from loading successfully. This topic discusses the most common issues and the steps that you can take to address them. For more information about how to install and register feature extensions, see How to: Register and Manage Feature Extensions.
First Steps when a Feature Extension is not Loading
After you install and register your feature extension, you must restart Visual Studio. The first step that you should take after you restart Visual Studio is to display the Error List. If one or more extensions could not be loaded, errors might appear in the Error List. On the View menu, click Error List. If an error such as the following appears, your extension did not load correctly:
Failed to load extension MyBuildContributor.ModelStatisticsReport. Exception message: Could not load type 'MyBuildContributor.ModelStatisticsReport' from assembly 'MyBuildContributor, Version 1.0.0.0, Culture=neutral, PublicKeyToken=34fdfd7e8ae7c7a8'.
In some situations, for example if no .extensions.xml file was found, your extension will not load, but no errors will appear.
Diagnosing Why Your Extension Failed to Load
Reasons why your extension might fail to load include the following:
The extension file contains one or more errors
The extension assembly is not signed
The extensions.xml file was not found
The extension assembly was not found
The code in the extension does not extend the correct classes
Classes or members in the extension do not have the correct attributes
The Extension File Contains One or More Errors
The most common reason that an extension fails to load is that you have one or more of the following errors in your Extensions.XML file:
Incorrect type name
Incorrect assembly name
Incorrect version number
Incorrect public key token
For information about how to author an extensions.xml file, see How to: Register and Manage Feature Extensions.
The Extension Assembly is not Signed
If your extension assembly is not signed, it cannot be loaded by Visual Studio. To sign an extension assembly, follow these steps:
To sign and build the assembly
Open the solution that contains your extension project.
On the Project menu, click MyExtensionProject Properties, where MyExtensionProject is the name of the project that contains the feature extension that you want to sign.
Click the Signing tab.
Click Sign the assembly.
In Choose a strong name key file, click <New>.
In the Create Strong Name Key dialog box, in Key file name, type MyRefKey.
(optional) You can specify a password for your strong name key file.
Click OK.
On the File menu, click Save All.
On the Build menu, click Build Solution.
Next, you must install and register the assembly so that it will be loaded when you deploy database projects.
The Extensions.XML File was not Found
If you did not provide an XML file to register your extension with Visual Studio, your extension will not be loaded. Typically, you copy the MyAssembly.Extensions.XML file to the %Program Files%\Microsoft Visual Studio 10.0\VSTSDB\Extensions\MyExtensions folder, where MyAssembly is the name of your extension.
Note
We recommend that you do not copy your XML files directly into the [Program Files]\Microsoft Visual Studio 10.0\VSTSDB\Extensions folder. If you use a subfolder instead, you will prevent accidental changes to the other files that are provided with Visual Studio.
For more information about how to create an Extensions.XML file, see How to: Register and Manage Feature Extensions.
The Extension Assembly was not Found
If you did not copy your extension assembly to the Extensions folder, your extension will not be loaded. Typically, you copy the MyAssembly.dll and MyAssembly.pdb files to the %Program Files%\Microsoft Visual Studio 10.0\VSTSDB\Extensions\MyExtensions folder, where MyAssembly is the name of your extension.
Note
We recommend that you do not copy your XML files directly into the [Program Files]\Microsoft Visual Studio 10.0\VSTSDB\Extensions folder. If you use a subfolder instead, you will prevent accidental changes to the other files that are provided with Visual Studio Premium.
The Code in the Extension Does Not Extend the Correct Classes
For each type of feature extension, your primary class extends a specific base class. If you do not inherit from the correct base class, your extension will not function correctly. For more information, see the corresponding walkthrough.
Classes or Members in the Extension Do Not Have the Correct Attributes
For each type of feature extension, the class must have an attribute that declares the type of database schema providers with which the extension is compatible. In addition, some extensions require additional attributes on one or more of the class methods. For more information, see the corresponding walkthrough.
See Also
Concepts
Create Custom Database Refactoring Types or Targets
Create and Register Additional Rules for Analyzing Database Code
Generate Specialized Test Data with a Custom Data Generator
Define Custom Conditions for Database Unit Tests
Customize Database Build and Deployment by Using Build and Deployment Contributors