microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not load `System.Runtime.CompilerServices.Unsafe.dll`

TymurGubayev opened this issue · comments

For some reason, it does work on my machine but doesn't on another, where it fails to load the System.Runtime.CompilerServices.Unsafe.dll, even so the file is present and the binding redirect is there.

One difference is, on my machine VS2022 was installed first and VS2019 after, and on the other only VS2019 is installed.

      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\System.Runtime.CompilerServices.Unsafe.dll' or one of its dependencies. The system cannot find the file specified.

This file is present, is has version 5.0.20.51904.

Strangely, fusion log shows another version is succesefully loaded (I don't know how to find out where did it come from).

*** Assembly Binder Log Entry  (7/13/2022 @ 9:35:38 AM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\admin\Desktop\myProg\myProg.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/Users/admin/Desktop/myProg/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = myProg.exe
Calling assembly : System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().

Hello @TymurGubayev,

We apologize for the late response.
Is this issue still relevant?
Do you need our assistance?

@YuliiaKovalova funny thing, I don't quite remember what happened with this problem from over a year ago. Let's assume it's not relevant anymore.