【发布时间】:2014-12-23 19:53:32
【问题描述】:
正如标题所说,我基于VS2013中的“Visual Studio Package”模板项目开发了一个VSIX包。
这是一个非常简单的扩展,在文本编辑器中添加了一个装饰层,代码是here。
我正在尝试添加对 VS2012 的兼容性,但没有成功。
我已经修改了 .vsixmanifest 中的安装目标,事实上,当我启动安装程序时,它会询问我是否也想安装到 VS2012。扩展程序安装得很好,但是我在 IWpfTextViewCreationListener 上激活时遇到了一个问题(只要我打开一个文本文件进行编辑),它似乎与项目中引用的 DLL 的版本有关。
我在 ActivityLog 中得到的是:
<entry>
<record>862</record>
<time>2014/10/28 11:23:29.757</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.ComponentModel.Composition.CompositionContractMismatchException: Cannot cast the underlying exported value of type 'Recoding.WhereAmI.WhereAmIFactory (ContractName="Microsoft.VisualStudio.Text.Editor.IWpfTextViewCreationListener")' to type 'Microsoft.VisualStudio.Text.Editor.IWpfTextViewCreationListener'.
 at System.ComponentModel.Composition.ExportServices.CastExportedValue[T](ICompositionElement element, Object exportedValue)
 at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
 at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedLazyOfTM>b__1()
 at System.Lazy`1.CreateValue()
 at System.Lazy`1.LazyInitValue()
 at System.Lazy`1.get_Value()
 at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata](Object errorSource, Lazy`2 provider)</description>
</entry>
它引用了 12.0 的 Microsoft.VisualStudio.Text.UI.Wpf.dll,我尝试将引用标记为“特定版本”= false,但问题仍然存在。
附带说明,我无法在加载扩展的实验模式下运行 VS2012。我将项目的“启动外部程序”选项更改为 Visual Studio 11.0\Common7\IDE\devenv.exe ,它在实验模式下运行,但没有加载扩展。为了测试它,我必须生成 VSIX 并将其安装到 VS2012(这很痛苦)。
关于如何进行的任何建议?真的和汇编错误版本有关吗?
【问题讨论】:
-
您的 InstallTarget 不应该是 Version="[11.0,]",还尝试删除对 Microsoft.VisualStudio.MPF 的依赖。我通常会删除那个以使其同时工作
-
是的,你在github上看到的版本和我本地的不一致,我已经添加了安装目标来匹配VS2012。扩展安装正确,问题出在运行时,因为 wpf 激活了扩展的工厂
-
另外,请注意我没有 VS2012 的 sdk,但只有 VS2013。不知道是否有某种关联...
-
请查看我对 11.0 程序集的回答,它在 VS2012 和 VS2013 中为我使用您的插件。关于实验模式,我也没有办法解决
-
您能否澄清一下您在 extension.vsixmanifest 中进行了哪些更改以在 VS2012 中安装扩展程序。我从您的扩展中添加了代码,但它仍然只提供 VS2013:
标签: wpf visual-studio visual-studio-2012 vsix