未触发 Visual Studio 装饰扩展事件 [英] Visual Studio adornment extension events not being fired

查看:20
本文介绍了未触发 Visual Studio 装饰扩展事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的 Visual Studio 插件创建一个基本的装饰功能.我已经有一个工具窗口和一些命令设置,我正在尝试让 adronment 工作.

I'm trying to create a basic adornment function for my visual studio plugin. i already have a tool window and some commands set up, and i am in the process of trying to get adronment to work.

按照微软的走过之后,我的印象是将创建侦听器类添加到我的项目中并按原样设置它;Visual Studio 会自动加载我插件的那部分并为我创建监听器.然而,我正在侦听的事件似乎从未被触发.

Following this walk through from Microsoft, i was under the impression that adding the creation listener class to my project and setting it up as is in the walk though; visual studio would automatically load that part of my plugin and create the listener for me. The event which i am listening for never seems to be fired however.

以下是我正在使用的代码的主要片段.

Below is the main snippet of the code i am using.

[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("code")]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
internal sealed class Flare_Client_AdornmentFactory : IWpfTextViewCreationListener {


    public void TextViewCreated(IWpfTextView textView) {
        new Flare_Client_Adornment(textView);
    }
}

我想我可能遗漏了一个步骤,我必须在某个存在的地方注册,但我不知道去哪里找.我需要做什么才能注册此活动?

I think that i may be missing a step and i have to register somewhere that this exists, but i do not know where to look. What do i have to do to get this event registered?

推荐答案

我已经找出问题所在.当我向现有 VsPackage 项目添加装饰时,我需要在我的 vsixmanifest 中设置另一个资产,以允许我的项目也是 MefComponent(这是装饰的项目类型).

I have worked out what the issue was. As i was adding adornment to an existing VsPackage project, i needed to set another Asset in my vsixmanifest to allow my project to also be an MefComponent (which is the project type for adornment).

下面是我的 vsixmanifest 截图,以帮助更好地展示我的解决方案.

Below is a screenshot of my vsixmanifest to help show my solution better.

这篇关于未触发 Visual Studio 装饰扩展事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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