c# - IVsTextViewCreationListener 在 VSIX 项目从 2012 年更新到 2013 年后不起作用

标签 c# visual-studio-2013 vsix

我有一个针对 Visual Studio 2012 的 VSIX 项目,它运行良好。 但是当我更新项目以针对 Visual Studio 2013 时。 未调用后续函数“VsTextViewCreated”

using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.Utilities;
using SnippetsUI;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VSIXProject1
{
    class CompletionHandler
    {
        [Export(typeof(IVsTextViewCreationListener))]
        [ContentType("CSharp")]
        [Name("CodeCompletionTypeZero")]
        [TextViewRole(PredefinedTextViewRoles.Editable)]
        internal class CompletionHandlerProvider : IVsTextViewCreationListener
        {
            [Import]
            internal IVsEditorAdaptersFactoryService _adapterService = null;
            [Import]
            internal ICompletionBroker _completionBroker { get; set; }
            [Import]
            internal SVsServiceProvider _serviceProvider { get; set; }

            public void VsTextViewCreated(IVsTextView textViewAdapter)
            {
                Printer.Print("VsTextViewCreated");
                ITextView textView = _adapterService.GetWpfTextView(textViewAdapter);
                if (textView == null)
                {
                    return;
                }
                return;
            }
        }
    }
}

此外,如果我想在这一行设置一个断点:“Printer.Print("VsTextViewCreated");" 我得到“当前不会命中断点。没有为该文档加载任何符号”

感谢所有读到这里的人:)

最佳答案

删除

“C:\Users\您的用户名\AppData\Local\您的公司名称” 和 "C:\Users\你的用户名\AppData\Local\Microsoft\VisualStudio\12.0Exp"

此外,修改您的 VSIXxShellExtensions list 文件并将您的包标记为“MEFComponent”。

这也是个好话题:VSIX extension for VS2012 not running when debugging

关于c# - IVsTextViewCreationListener 在 VSIX 项目从 2012 年更新到 2013 年后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20188402/

相关文章:

.net - 检测 VSPackage 中的 Visual Studio 版本

c# - VSIX 项目缺少可扩展性项模板

c# - Unity3d 中未处理的异常 : System. Reflection.ReflectionTypeLoadException

c# - 如何修复 "The type or namespace name could not be found"?

c# - 如何在代码webtest中获取响应正文?

c++ - TDD 让我除以零。可以吗?

visual-studio-2015 - 使用 VS 2015 实验实例调试在 VS 2017 中创建的 VSIX

c# - 查看 Excel 是否处于 .NET 中的单元格编辑模式的解决方法

c# - 在没有 Console.ReadKey() 的情况下暂停并等待 C# 中的输入

c++ - VS C++ 突然没有符号,无法调试