I'm developing some code snippet, and I experienced that Visual Studio doesn't automatically add Reference to specified assembly and doesn't import the specified namespace.
My snippet definition is:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>MyTryCatch</Title>
<Shortcut>myTryCatch</Shortcut>
</Header>
<Snippet>
<References>
<Reference>
<Assembly>MyAssembly.dll</Assembly>
</Reference>
</References>
<Imports>
<Import>
<Namespace>MyNamespace</Namespace>
</Import>
</Imports>
<Declarations>
<Object Editable="true">
<ID>Message</ID>
<Type>String</Type>
<ToolTip>Error message</ToolTip>
<Default>message</Default>
<Function></Function>
</Object>
</Declarations>
<Code Language="csharp" Kind="" Delimiter="$">
<![CDATA[try
{
}
catch (Exception exception)
{
throw new MyNamespace.MyException("$Message$", exception);
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
</CodeSnippets>
Note that I'm referencing a custom MyAssembly.dll that is visible from "Add Reference" popup (.NET Tab).
When I use the above snippet by myTryCatch shortcut, I'm able to see the snippet code but no Reference added and no Import made.
How I can fix or debug this issue?
Thanks in advance!
It sounds like the problem is your choice of language. Only VB.Net supports reference assemblies and importing of namespaces from a code snippet. The C# engine will ignore these elements.
Reference: http://msdn.microsoft.com/en-us/library/ms171438.aspx