Monday, 20 February 2017

Visual Studio 2010 Code Snippets fail on VS 2015 with "Object reference not set to an instance of an object"

We've recently had a problem with some old Visual Studio 2010 code snippets written in C# failing when used in Visual Studio 2015 with an "Object reference not set to an instance of an object" error.


It appears that the code snippets now require the title value to be set.



<CodeSnippet Format="1.0.0">
  <Header>
    <Title>Add collection editor attribute</Title>
    <Shortcut>coledit</Shortcut>
  </Header>
  <Snippet>
    <Code Language="csharp">
      <![CDATA[[Editor(typeof(AdvancedCollectionEditor), typeof(UITypeEditor))]]]>
    </Code>
  </Snippet>
</CodeSnippet>



Setting the title will immediately remedy the issue, but another gotcha is....

Any code snippet in the document missing the title element will cause subsequent code snippets to fail.

No comments:

Post a Comment