RegAsm failing for a .NET 4.0 assembly using Microsoft.Bcl.Async

后端 未结 1 1903
不知归路
不知归路 2020-12-19 16:55

RegAsm failing for a .NET 4.0 assembly using Microsoft.Bcl.Async with the following message:

RegAsm : error RA0000 : Could not load file or assembly          


        
相关标签:
1条回答
  • 2020-12-19 17:34

    The solution I have come up with is a hack:

    • copied RegAsm.exe and RegAsm.exe.config from C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe to a local folder where MyAssembly.dll is;

    • edited RegAsm.exe.config to look like this:

    <?xml version ="1.0"?>
    <configuration>
        <startup useLegacyV2RuntimeActivationPolicy="true">
            <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
            <supportedRuntime version="v4.0" sku="client" />
        </startup>
    
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.6.6.0" newVersion="2.6.6.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.6.6.0" newVersion="2.6.6.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.6.6.0" newVersion="2.6.6.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    
    </configuration>
    
    • now, running RegAsm.exe /codebase MyAssembly.dll works fine as expected.

    Interestingly, useLegacyV2RuntimeActivationPolicy="true" has already been there in the standard RegAsm.exe.config, but alone it did not help.

    I think this is the same bug reported here: https://connect.microsoft.com/VisualStudio/feedback/details/789318/asyncpack-system-io-fileloadexception-could-not-load-file-or-assembly-system-threading-tasks-version-1-5-11-0.

    0 讨论(0)
提交回复
热议问题