我想为我的需要构建一个简单的SSMS扩展。我创建了VSIX项目,它在VS中完美运行。但是,当我尝试在SSMS中进行测试时,它什么也没做。我设置了将内容复制到SSMS的Extensions文件夹中的复选框,并将SkipLoad添加到了注册表中。我可以在菜单中看到扩展名,但是当我单击时-没有任何反应,没有选中Execute方法。
当我看到日志时-我的扩展程序的GUID出现以下异常:
<entry>
<record>2409</record>
<time>2019/03/22 21:55:41.171</time>
<type>Error</type>
<source>VisualStudio</source>
<description>SetSite failed for package [CommandPackage]Source: 'Microsoft.VisualStudio.Shell.15.0' Description: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
 at Microsoft.VisualStudio.Shell.AsyncPackage.Microsoft.VisualStudio.Shell.Interop.IAsyncLoadablePackageInitialize.Initialize(IAsyncServiceProvider asyncServiceProvider, IProfferAsyncService profferAsyncService, IAsyncProgressCallback progressCallback)</description>
<guid>{D88E201F-ECED-431B-8698-EB110F922E21}</guid>
<hr>80004003 - E_POINTER</hr>
</entry>
请告知
Execute方法非常简单,但甚至没有被击中:
private async void Execute(object sender, EventArgs e)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
var dte = await package.GetServiceAsync(typeof(DTE)) as DTE;
Assumes.Present(dte);
if (dte.ActiveDocument == null)
return;
var selection = (TextSelection)dte.ActiveDocument.Selection;
var text = selection.
}
更新: 我遵循以下指示:https://www.codeproject.com/Articles/1243356/Create-Your-Own-SQL-Server-Management-Studio-SSMS 一个月前,它似乎可行,但现在已经失效-可能是在对SSMS进行了一些更新之后
也许我在某处使用了错误的版本?