问题
I've followed the steps listed in the walk through (http://msdn.microsoft.com/en-us/library/bb166360.aspx) for implementing and registering a LanguageService and I simply can't get it to work.
My package loads correctly, I can add functioning menu items and option pages, but I cannot open files registered to my service. When I attach a debugger, I can see my VSPackage being constructed, loaded, and having its FDoIdle method called twice. After that, experimental Visual Studio session goes off into the weeds and appears to get stuck in an infinite loop. If I try to save a .txt file as my file type, the file is saved correctly but it does not load in Visual Studio and I get an Object null exception.
I can see my problem mentioned in this question: Visual studio 2010 colourizers, intellisense and the rest. Where to start!
The resolution seems to be to not use the Managed Package Framework and instead use the Manage Extensibility Framework. That's great and all, but I'd really like to know what I'm doing wrong with my MPF LanguageService implementation.
Has anyone successfully created a LanguageService by using MPF? Can anyone direct me to a working example or walkthrough?
PROBLEM SOLVED!:
I did some further debugging and noticed the experimental Visual Studio instance getting stuck calling the following repeatedly:
Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.TryGetIndexForNativeItem(String name, IVsColorTable colorTable, Int32& colorTableIndex)
On a hunch I specified the RequestStockColors parameter to true in the ProvideLanguageServiceAttribute, and I can now open my file type. My simple scanner even has working syntax coloring!
回答1:
PROBLEM SOLVED!:
I did some further debugging and noticed the experimental Visual Studio instance getting stuck calling the following repeatedly:
Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.TryGetIndexForNativeItem(String name, IVsColorTable colorTable, Int32& colorTableIndex)
On a hunch I specified the RequestStockColors parameter to true in the ProvideLanguageServiceAttribute, and I can now open my file type. My simple scanner even has working syntax coloring!
来源:https://stackoverflow.com/questions/5211018/implementing-a-language-service-by-using-the-managed-package-framework