使用托管包框架实现语言服务
我已按照演练中列出的步骤进行操作 (http://msdn. microsoft.com/en-us/library/bb166360.aspx)用于实现和注册 LanguageService,但我根本无法让它工作。
我的包加载正确,我可以添加功能菜单项和选项页面,但无法打开注册到我的服务的文件。当我附加调试器时,我可以看到我的 VSPackage 正在构建、加载,并且其 FDoIdle 方法被调用两次。此后,实验性 Visual Studio 会话陷入混乱,似乎陷入了无限循环。如果我尝试将 .txt 文件保存为我的文件类型,该文件会正确保存,但不会在 Visual Studio 中加载,并且会出现对象空异常。
我可以看到这个问题中提到的我的问题: Visual studio 2010 着色器、智能感知等。从哪里开始!
解决方案似乎是不使用托管包框架,而是使用管理可扩展性框架。这很好,但我真的很想知道我的 MPF LanguageService 实现做错了什么。
有人使用 MPF 成功创建了 LanguageService 吗?谁能指导我一个工作示例或演练?
问题已解决!:
我做了一些进一步的调试,并注意到实验性的 Visual Studio 实例卡住了,反复调用以下命令:
Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.TryGetIndexForNativeItem(String name, IVsColorTable colorTable, Int32& colorTableIndex)
凭直觉,我指定了将 ProvideLanguageServiceAttribute 中的 RequestStockColors 参数设置为 true,我现在可以打开我的文件类型。我的简单扫描仪甚至具有有效的语法着色!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题已解决!:
我做了一些进一步的调试,并注意到实验性的 Visual Studio 实例卡住了,反复调用以下命令:
Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.TryGetIndexForNativeItem(String name, IVsColorTable colorTable, Int32& colorTableIndex)
凭直觉,我指定了将 ProvideLanguageServiceAttribute 中的 RequestStockColors 参数设置为 true,我现在可以打开我的文件类型。我的简单扫描仪甚至具有有效的语法着色!
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!