Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to Postgres db using 4.1.1 - Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, #2677

Open
juliangordon opened this issue Oct 7, 2019 · 7 comments

Comments

@juliangordon
Copy link

commented Oct 7, 2019

Hi,

Receiving the below error when using the new MSI - Version 4.1.1.

Error Message:
Test connection failed because of an error in initializing provider. Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

The error is experienced when referencing a NPGSL connection in Visual Studio, for SSIS.

Reproduce error:

  1. Create a SSIS solution in Visual Studio.
  2. Create a new NPGSQL postgres connection. Error is experienced when testing the connection.
@jsobell

This comment has been minimized.

Copy link

commented Oct 9, 2019

Same issue here when using the GAC registered library with LLBLGen

@FransBouma

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2019

It's odd, as npgsql has a dependency on System.Runtime.CompilerServices.Unsafe (>= 4.6.0) according to nuget.

   at System.Threading.Tasks.ValueTask`1.get_IsCompleted()
   at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Npgsql.NpgsqlConnection.Open()

Opening npgsql.dll in ilspy shows that it references system.runtime.compilerservices.unsafe, which loads just fine (v4.0.5.0) from the gac but indeed instantiating a connection fails at runtime.
Could it be the host is initially compiled against .net 4.5.2? (but runs on .net 4.8 ) ?

@Vashti42

This comment has been minimized.

Copy link

commented Oct 9, 2019

Following ... we are getting the same error message. Any status on a fix?

@Anuj0047

This comment has been minimized.

Copy link

commented Oct 10, 2019

Hi, I am getting the same error while updating Entity Model using "NPGSQL" in VS 2017

Could not load the assembly System.Runtime.CompilerServices.Unsafe.

Npgsql version: 4.1.1
PostgreSQL version: PostgreSQL 11.5
.NET Framework: 4.6.1

In all the C#.NET Applications (Web Application, Web and Windows Service), we are facing the same issue.

Could someone please help me with this issue?

Also, I have upgraded the Npgsql PostgreSQL Integration Extension to v4.1.1.2.

@saites

This comment has been minimized.

Copy link

commented Oct 11, 2019

I have the same issue with 4.1.1 after installing to GAC and trying to import data in Excel 2019. I'd reckon the problem is the same sort as #2356.

After uninstalling 4.1.1 and installing 4.0.9 (the 4.1.0 release tag does not have an MSI asset), I was able to successfully connect.

The dependencies appear to have been added to 4.1 as part of this commit, but they were backported to 4.0.11.

@roji

This comment has been minimized.

Copy link
Member

commented Oct 14, 2019

I'll try to investigate this in the coming days.

@elrito96

This comment has been minimized.

Copy link

commented Oct 16, 2019

Had the same problem with other 4 PCs. as @saites said,

I have the same issue with 4.1.1 after installing to GAC and trying to import data in Excel 2019. I'd reckon the problem is the same sort as #2356.

After uninstalling 4.1.1 and installing 4.0.9 (the 4.1.0 release tag does not have an MSI asset), I was able to successfully connect.

The dependencies appear to have been added to 4.1 as part of this commit, but they were backported to 4.0.11.

The problem was solved uninstalling the newest version (4.1.1) and installing 4.0.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.