locked
Code snippet failed to load

    Pergunta

  • 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.
    terça-feira, 28 de abril de 2009 20:21

Todas as Respostas

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

    LS
    terça-feira, 28 de abril de 2009 20:30
  • 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.
    terça-feira, 28 de abril de 2009 20:51
  • did you restart vs after removing them?
    terça-feira, 28 de abril de 2009 20:55
  • 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!
    terça-feira, 28 de abril de 2009 21:02
  • 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.
    • Marcado como Resposta Harry Zhu quinta-feira, 7 de maio de 2009 03:57
    • Não Marcado como Resposta Scoutn terça-feira, 12 de maio de 2009 19:03
    terça-feira, 5 de maio de 2009 09:46
  • Hi Harry -  I've tried that but the problem is still there. Any other suggestions?
    terça-feira, 12 de maio de 2009 19:03
  • 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
    terça-feira, 12 de maio de 2009 19:30
  • 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>
    quarta-feira, 13 de maio de 2009 16:04
  • 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
    quarta-feira, 13 de maio de 2009 17:31
  • 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.
    quarta-feira, 13 de maio de 2009 17:54
  • 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


    quarta-feira, 13 de maio de 2009 18:12
  • I appreciate your time. Unfortunately clearing the user data didn't help either. Oh well, life goes on. :)
    quarta-feira, 13 de maio de 2009 19:38
  • 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

    • Sugerido como Resposta Geert van Horrik quarta-feira, 9 de dezembro de 2009 20:24
    terça-feira, 26 de maio de 2009 14:08
  • Thanks Alot Harry ,,, it Works
    terça-feira, 15 de dezembro de 2009 12:15
  • 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.

     

    • Sugerido como Resposta jrummell quinta-feira, 17 de março de 2011 17:36
    terça-feira, 20 de julho de 2010 06:49
  • Renaming the ExpansionsXML.xml and restarting VS worked for me! 

    Thanks for posting your solution!

    segunda-feira, 13 de setembro de 2010 02:27
  • 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.
    quinta-feira, 17 de março de 2011 17:36
  • 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.

    quarta-feira, 6 de julho de 2011 19:41
  • This resolved my issue for VS 2010... I looked at the ExpansionsXML.xml file and numerous closing tags were missing.
    quarta-feira, 25 de janeiro de 2012 03:40
  • Indeed, removing %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions.xml fixes all the issues with non-working snippets. Thanks!

    • Sugerido como Resposta abatishchev segunda-feira, 7 de maio de 2012 07:48
    segunda-feira, 7 de maio de 2012 07:47
  • Removing the Extensions.xml file and restarting worked for me as well.

    Using VS 2010 


    Mike

    sexta-feira, 16 de novembro de 2012 14:49