【发布时间】:2014-09-04 11:31:35
【问题描述】:
我在我的 Word 插件中使用 Microsoft.Bcl.Async,我的插件被编译为一个 exe (test_addin.exe) 文件,它作为一个程序集从 Microsoft Word 加载,当我直接启动可执行文件时,一切正常很好,但是当我从 Word 运行它时,我收到一条错误消息,提示它无法加载 Systems.Threading.Tasks 程序集。
Could not load file or assembly System.Threading.Tasks...
看起来它与绑定重定向有关,当我尝试从 Word 运行应用程序时,它希望配置文件位于 'C:\Program Files (x86)\Microsoft Office\Office15' 文件夹中并命名为 WINWORD.exe.config,不幸的是这是不可能的,因为我可能无权访问该文件夹。
我的 test_addin.exe.config 文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我已尝试将 AppDomain.CurrentDomain.SetupInformation.ConfigurationFile 设置为指向正确的路径,但似乎没有帮助,是否有其他方法可以使其适用于 Office 加载项?
【问题讨论】:
标签: c# office-interop .net-assembly assembly-resolution