我有一个 VS 扩展,它应该使用 Gmail api 向我公司的某些用户发送邮件。
在开发过程中我遇到了一个常见问题System.Net.Http.Primitives
Google API 中的版本有些混乱。
The 共同解决方案因为这是把bindingRedirect
在 app.config 中将所有调用重定向到新的最新版本的库。就像下面这样:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
但是,当我的输出是 Vsix 包时,这似乎不起作用。生成的 Vsix 甚至没有 app.config。
我知道一个解决方案说要添加bindingRedirect
to machine.config
文件,但我的扩展被其他一些人使用,我不想强迫他们将东西放入他们的机器配置文件中。
还有其他解决方案吗?
这是一年多前回答的,但我找到了一种更好的方法来做到这一点ProvideBindingRedirectionAttribute
。这会将绑定重定向添加到 devenv,并确定正确的版本。详情可查here,但相关部分在这里:
通过使用 ProvideBindingRedirection 属性,您可以为可扩展组件的升级安装指定绑定重定向。当您发布可扩展的 Visual Studio 组件时,此属性可以防止该组件的用户必须安装旧版本的依赖组件。如果使用 ProvideBindingRedirection 属性,则无需手动更新 exe.config 文件即可将旧程序集版本的用户重定向到新版本。
添加 ProvideBindingRedirection 程序集属性是将绑定重定向条目添加到 pkgdef 文件的一种简单方法。 pkgdef 文件用于安装扩展。
以下示例显示了 AssemblyInfo.cs 或 AssemblyInfo.vb 文件中的 ProvideBindingRedirection 条目:
[assembly: ProvideBindingRedirection(AssemblyName = "ClassLibrary1",
NewVersion = "3.0.0.0", OldVersionLowerBound = "1.0.0.0",
OldVersionUpperBound = "2.0.0.0")]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)