Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe'

Trying to use SQLTypeProvider with postgres I get the following errorwhen running

dotnet build

error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [/home/sashan/code/titan/src/Server/Server.fsproj]

my data provider is this:

type SQL = SqlDataProvider< 
                  ConnectionString = pg_dev_conn_string,
                  DatabaseVendor = Common.DatabaseProviderTypes.POSTGRESQL,
                  UseOptionTypes = true >

If I change it to the following

type SQL = SqlDataProvider< 
              ConnectionString = pg_dev_conn_string,
              DatabaseVendor = Common.DatabaseProviderTypes.POSTGRESQL,
              ResolutionPath = "/home/sashan/code/dotnet/2.1.500/sdk/NuGetFallbackFolder/system.runtime.compilerservices.unsafe/4.5.1/lib/netcoreapp2.0",
              UseOptionTypes = true >

The error goes away but I don't understand why. The fix seems really weird. Why should I have to point it to a file outside of my project? Shouldn't the System.Runtime.CompilerServices.Unsafe.dll be somewhere in one of project's subdirectories where the compiler can find it?

like image 816
sashang Avatar asked Dec 22 '18 03:12

sashang


People also ask

What is System Runtime CompilerServices unsafe?

Runtime. CompilerServices. Unsafe state that it: Contains generic, low-level functionality for manipulating pointers.

Can not load file or assembly?

In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.


2 Answers

i fix it comenting in web.config the entry that contains System.Runtime.CompilerServices.Unsafe

like image 163
Giancarlo Molina Avatar answered Oct 19 '22 02:10

Giancarlo Molina


I had the same problem with unity container and after updated this dll from Nuget my problem solved

like image 7
Maryam Avatar answered Oct 19 '22 00:10

Maryam