I'm using Microsoft.Bcl.Async in my Word addin, my addin is compiled as an exe (test_addin.exe) file, that is loaded as an assembly from Microsoft Word, when I start the executable directly, everything's working fine, but when I run it from Word, I'm getting an error saying that it failed to load the Systems.Threading.Tasks assembly.
Could not load file or assembly System.Threading.Tasks...
It looks like that its related to the binding redirects, when I try to run the application from Word it expects the config file to be located in the 'C:\Program Files (x86)\Microsoft Office\Office15'
folder and be named WINWORD.exe.config
, that is unfortunately impossible because I might not have access to that folder.
My test_addin.exe.config file:
<?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>
I have tried setting AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
to point to the correct path, but it doesn't seem to help, are there other ways to make it work for an Office add-in?
Assembly.Load
overAssembly.LoadFrom
;LoadFrom
does not deduplicate loaded assemblies and leading the common language runtime to believe that the multiple instances of the assembly are different assemblies. – Oxyacetylene