If you’re testing the installer for your Visual Studio Add-In and you get the following error when launching Visual Studio:
"Switch from current encoding to specified encoding not supported"
and your .AddIn file looks completely normal when you open it in a text editor, then you're most likely not writing your .AddIn file in Unicode. Since the .AddIn usually specifies:
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
Visual Studio expects the file type to be Unicode, so if you wrote your .AddIn file to disk using something like:
You'll need to adapt your code to something like:
File.WriteAllText(addinFile, addInConfig, System.Text.Encoding.Unicode);
To make sure that the file is Unicode.
Hope that helps!
One of the big changes in Visual Studio 2010 is the introduction of the WPF based UI which means that (amongst other things) you can now host WPF windows directly within the IDE without having to wrap them inside WinForm controls.
Unfortunately you may notice that if you create a simple WPF UserControl and then try to create a ToolWindow from it using
CreateToolWindow2, you’ll run into the following Managed Debugging Assistant:
Managed Debugging Assistant 'NonComVisibleBaseClass' has detected a problem in 'c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe'.
Additional Information: A QueryInterface call was made requesting the default IDispatch interface of COM visible managed class 'WPFUserControlAddIn.WPFToolWindow'.
However since this class does not have an explicit default interface and derives from non COM visible class 'System.Windows.Controls.UserControl', the QueryInterface call will fail.
This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.
If you follow through this error message it will lead you to the MSDN page for this error (here) and from there to the page that holds the solution.
Add the following to your
[yourfile].xaml.cs around your class declaration:
class [yourclass] : UserControl, IDispatch
Note! Don’t forget the addition of the
IDispatch implementation (there’s nothing to implement, don’t worry). Without it you’ll get
mscordb.lib and a
null in your
ref object (the last parameter to
Got a Sample For Us?
You bet – grab the sample solution. All you need to do is extract, add the .addin file to you AddIns directory (under Documents\Visual Studio 2010\Addins) and away you go.