在VS 2012中导入SvsServiceProvider [英] Importing SvsServiceProvider in VS 2012

查看:97
本文介绍了在VS 2012中导入SvsServiceProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual Studio可扩展性的新手,我尝试从VS 2012 SDK实现Microsoft演练之一(显示语句完成)。我在演练中上一节课有些困难。问题是我收到未定义 SVsServiceProvider 的错误。我已经导入 Microsoft.VisualStudio.Shell

I am new to Visual Studio Extensibility and am try to implement one of the Microsoft Walkthroughs from the VS 2012 SDK (Displaying Statement Complete). I am having some difficulty with one class in the walkthrough. The problem is that I get a an error that SVsServiceProvider is not defined. I have imported Microsoft.VisualStudio.Shell.

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.ComponentModel.Composition
Imports System.Runtime.InteropServices
Imports Microsoft.VisualStudio
Imports Microsoft.VisualStudio.Editor
Imports Microsoft.VisualStudio.Language.Intellisense
Imports Microsoft.VisualStudio.OLE.Interop
Imports Microsoft.VisualStudio.Shell
Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Editor
Imports Microsoft.VisualStudio.TextManager.Interop
Imports Microsoft.VisualStudio.Utilities


<Export(GetType(IVsTextViewCreationListener))>
<Name("token completion handler")>
<ContentType("plaintext")> <TextViewRole(PredefinedTextViewRoles.Editable)>
Friend Class TestCompletionHandlerProvider
Implements IVsTextViewCreationListener

<Import()>
Friend AdapterService As IVsEditorAdaptersFactoryService = Nothing
<Import()>
Friend Property CompletionBroker() As ICompletionBroker
<Import()>
Friend Property ServiceProvider() As SVsServiceProvider

Public Sub VsTextViewCreated(ByVal textViewAdapter As IVsTextView) Implements IVsTextViewCreationListener.VsTextViewCreated
    Dim textView As ITextView = AdapterService.GetWpfTextView(textViewAdapter)
    If textView Is Nothing Then
        Return
    End If

    Dim createCommandHandler As Func(Of TestCompletionCommandHandler) = Function() New TestCompletionCommandHandler(textViewAdapter, textView, Me)
    textView.Properties.GetOrCreateSingletonProperty(createCommandHandler)
End Sub


推荐答案

如Simon在对原始问题的评论中所述,添加对以下内容的引用:

As posted by Simon in the comments on the original question, add a reference to:

Microsoft.VisualStudio.Shell.Immutable.10.0.dll

如果使用的是 Microsoft.VisualStudio.Shell。 Immutable.11.0.dll ,那么您将遇到一个空的 SvsServiceProvider

If you are using Microsoft.VisualStudio.Shell.Immutable.11.0.dll then you will encounter a null SvsServiceProvider.

这篇关于在VS 2012中导入SvsServiceProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆