Code snippet failed to load
-
2009年4月28日 20:21I 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.
すべての返信
-
2009年4月28日 20:30Do you get and warning signs on your folders in code snippet manager?LS
-
2009年4月28日 20:51Yes, 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.
-
2009年4月28日 20:55did you restart vs after removing them?
-
2009年4月28日 21:02I 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!
-
2009年5月5日 9:46モデレータ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.- 回答としてマーク Harry ZhuModerator 2009年5月7日 3:57
- 回答としてマークされていない Scoutn 2009年5月12日 19:03
-
2009年5月12日 19:03Hi Harry - I've tried that but the problem is still there. Any other suggestions?
-
2009年5月12日 19:30モデレータ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 -
2009年5月13日 16:04
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> -
2009年5月13日 17:31モデレータ
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 -
2009年5月13日 17:54The 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.
-
2009年5月13日 18:12モデレータ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 -
2009年5月13日 19:38I appreciate your time. Unfortunately clearing the user data didn't help either. Oh well, life goes on. :)
-
2009年5月26日 14:08
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
- 回答の候補に設定 Geert van Horrik 2009年12月9日 20:24
-
2009年12月15日 12:15Thanks Alot Harry ,,, it Works
-
2010年7月20日 6:49
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.
- 回答の候補に設定 jrummell 2011年3月17日 17:36
-
2010年9月13日 2:27
Renaming the ExpansionsXML.xml and restarting VS worked for me!
Thanks for posting your solution!
-
2011年3月17日 17:36
This worked for me as well.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.
- 回答の候補に設定 smokinsausage 2011年7月6日 19:40
- 回答の候補の設定解除 smokinsausage 2011年7月6日 19:40
- 回答の候補に設定 Keenan NewtonMicrosoft Employee 2012年1月25日 3:37
- 回答の候補の設定解除 Keenan NewtonMicrosoft Employee 2012年1月25日 3:40
-
2011年7月6日 19:41
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.
- 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.
-
2012年1月25日 3:40This resolved my issue for VS 2010... I looked at the ExpansionsXML.xml file and numerous closing tags were missing.
-
2012年5月7日 7:47
Indeed, removing %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions.xml fixes all the issues with non-working snippets. Thanks!
- 回答の候補に設定 abatishchev 2012年5月7日 7:48
-
2012年11月16日 14:49
Removing the Extensions.xml file and restarting worked for me as well.
Using VS 2010
Mike

