locked
Code snippet failed to load

    Question

  • I am getting the following error from VS 2008. 'Code Snippet titled [Method Stub - Body] failed to load.  Verify that refactoring snippets are recognized in the Code Snippet Manager and that the snippet files are valid on disk.' This happens when I try to override a method using intellisense or when I try to implement an interface.

    I have tried repairing Visual Studio, as well as trying to import the snippets from another installation that works. I have removed and added the folders as well. (C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Refactoring).

    I'm at a loss here. Does anyone have any suggestions? I've searched for a solution but there isn't much out there.
    Tuesday, April 28, 2009 8:21 PM

All replies

  • Do you get and warning signs on your folders in code snippet manager?

    LS
    Tuesday, April 28, 2009 8:30 PM
  • Yes, I had a couple on some of the Excel folders under Office Development. I removed the Office Development folder, but it didn't resolve the problem.
    Tuesday, April 28, 2009 8:51 PM
  • did you restart vs after removing them?
    Tuesday, April 28, 2009 8:55 PM
  • I just tried removing all the folders from the snippet manager, shutting down VS, renamed C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033\SnippetsIndex.xml to .old, renamed C:\Users\[user]\AppData\Local\Microsoft\VisualStudio\9.0\1033\ExpansionsXML.xml to .old, restarted VS, and I am still getting the error. Frustrating! I wish I could remember what I did to cause this to happen!
    Tuesday, April 28, 2009 9:02 PM
  • Hi,

    Please take the following steps:

    1 open code snippet manager(ctrl+k,ctrl+b).
    2 select the language (such as c#).
    3 add the three folders(  Refactoring、Visual C#、OfficeDevelopment) which locate at :
    C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033.

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Harry Zhu Thursday, May 07, 2009 3:57 AM
    • Unmarked as answer by Scoutn Tuesday, May 12, 2009 7:03 PM
    Tuesday, May 05, 2009 9:46 AM
  • Hi Harry -  I've tried that but the problem is still there. Any other suggestions?
    Tuesday, May 12, 2009 7:03 PM
  • 1) Go to <VSDir>\VC#\Snippets\1033\Refactoring. 
    2) Open MethodStub.snippet.
    3) Verify the snippet can be opened in an XML viewer such as VS or IE (probably have to rename it to XML first).
    4) If that doesn't work then post the file contents so we can look at it.

    Also please confirm what edition and SP of VS2008 you are running and if you have any third party addins installed that might impact the snippets such as CodeRush or ReSharper.

    Michael Taylor - 5/12/09
    http://p3net.mvps.org
    Tuesday, May 12, 2009 7:30 PM
  • Michael,

    I am using version 9.0.30729.1 of VS.

    I renamed the file to MethodStud.snippet.xml and it opened fine in IE. I did have ReSharper installed but have since uninstalled it and then repaired the VS installation. Below is the contents of the MethodStub snippet.

    <?xml version="1.0" encoding="utf-8"?>
    <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
        <CodeSnippet Format="1.0.0">
            <Header>
                <Title>Method Stub - Body</Title>
                <Description>Snippet for generating method stub with a body</Description>
                <Author>Microsoft Corporation</Author>
                <SnippetTypes>
                    <SnippetType>Refactoring</SnippetType>
                </SnippetTypes>
            </Header>
            <Snippet>
                <Declarations>
                    <Literal Editable="true">
                        <ID>signature</ID>
                        <Default>signature</Default>
                    </Literal>
                    <Literal>
                        <ID>Exception</ID>
                        <Function>SimpleTypeName(global::System.NotImplementedException)</Function>
                    </Literal>
                </Declarations>
                <Code Language="csharp">
                    <![CDATA[$signature$
    {
     	$end$throw new $Exception$();
    }]]>
                </Code>
            </Snippet>
        </CodeSnippet>
    </CodeSnippets>
    Wednesday, May 13, 2009 4:04 PM
  • If you click on a method call somewhere in your code and then press Ctrl+K,M what happens?  Does the problem occur on a new project as well?

    Michael Taylor - 5/13/09
    http://p3net.mvps.org
    Wednesday, May 13, 2009 5:31 PM
  • The same error occurs with Ctrl+K,M. It happens with new projects as well. It seems to only be the MethodStub snippets as the others in the Refactoring directory work.
    Wednesday, May 13, 2009 5:54 PM
  • At this point I'd say the snippet is valid and something else is causing the failure.  Whether it was ReSharper or something else I can't say.  You don't happen to have an extra set of snippets in the snippet manager that might collide with the existing one do you?

    The only thing that I can think of at this point is to try deleting your user data for VS (AppData, etc.) and then see if that resolves the problem.  It's a long shot at this point.  You might also consider looking in the Windows Event Log.  VS will generate warnings in the log for errors in templates.  I'm not sure if it does for snippets as well.

    Michael Taylor - 5/13/09
    http://p3net.mvps.org


    Wednesday, May 13, 2009 6:12 PM
  • I appreciate your time. Unfortunately clearing the user data didn't help either. Oh well, life goes on. :)
    Wednesday, May 13, 2009 7:38 PM
  • I had the same message. It may not be the same issue because it was easy to repair, but in case :

    In the Code Snippet Manager (ctrl+k,ctrl+b), my "Refactoring" and "Visual C#" folders were empty (no items).

    1/ I removed both of them
    2/ I clicked "Add...",
    3/ I Selected the folder "C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Refactoring"
    5/ I Did the same with the Visual C# folder.

    Then I could see the items inside the folder, like in this screenshot :
    http://www.codeguru.com/dbfiles/get_image.php?id=10793&lbl=SNIP07_JPG&ds=20051020

    Tuesday, May 26, 2009 2:08 PM
  • Thanks Alot Harry ,,, it Works
    Tuesday, December 15, 2009 12:15 PM
  • I just had the same issue with VS2008; I tried repairing VS, uninstalling/reinstalling, and removing/adding folders in code snippet manager; nothing worked.

    Finally what resolved it for me was renaming ExpansionsXML.xml located in C:\Users\<your username>\AppData\Local\Microsoft\VisualStudio\9.0\1033\, and restarting VS.  This regenerated the file, and resolved the issue.   I still have no idea what caused this - it started suddenly while I was coding, out of the blue.  Pretty frustrating.  I was actually on the verge of re-installing Windows when I finally fixed it.

     

    • Proposed as answer by jrummell Thursday, March 17, 2011 5:36 PM
    Tuesday, July 20, 2010 6:49 AM
  • Renaming the ExpansionsXML.xml and restarting VS worked for me! 

    Thanks for posting your solution!

    Monday, September 13, 2010 2:27 AM
  • Finally what resolved it for me was renaming ExpansionsXML.xml located in C:\Users\<your username>\AppData\Local\Microsoft\VisualStudio\9.0\1033\, and restarting VS.  This regenerated the file, and resolved the issue.   I still have no idea what caused this - it started suddenly while I was coding, out of the blue.  Pretty frustrating.  I was actually on the verge of re-installing Windows when I finally fixed it.

     

    This worked for me as well.
    Thursday, March 17, 2011 5:36 PM
  • Someone else logged into my computer and tested this. The code snippets worked under his login. This proved that the issue was a profile setting. I fixed this by doing two things:

    • I renamed the 9.0 folder to 9.0_test (because I didn't want to delete it just yet) found in Application Data and in Local Settings.
      • D:\documents and settings\'your user name'\Application Data\Microsoft\VisualStudio\9.0
      • D:\documents and settings\'your user name'\Local Settings\Application Data\Microsoft\VisualStudio\9.0

    I then opened VS2008 and tested snippets. Everything worked fine.

    Wednesday, July 06, 2011 7:41 PM
  • This resolved my issue for VS 2010... I looked at the ExpansionsXML.xml file and numerous closing tags were missing.
    Wednesday, January 25, 2012 3:40 AM
  • Indeed, removing %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions.xml fixes all the issues with non-working snippets. Thanks!

    • Proposed as answer by abatishchev Monday, May 07, 2012 7:48 AM
    Monday, May 07, 2012 7:47 AM
  • Removing the Extensions.xml file and restarting worked for me as well.

    Using VS 2010 


    Mike

    Friday, November 16, 2012 2:49 PM