question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assembly loading error

See original GitHub issue

Steps to reproduce

string query = “select * from table”; CommandParams commandParams = null; IDbConnection cnx = new NpgsqlConnection(info.ConnectionString); IDbCommand cmd = new NpgsqlCommand(query, cnx as Npgsql.NpgsqlConnection); if (commandParams != null) foreach (CommandParam cp in commandParams) cmd .Parameters.AddWithValue(cp.ParameterName, cp.Value); cnx.Open();

The issue

Return this : Could not load file or assembly ‘System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

[FileLoadException: Could not load file or assembly ‘System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Threading.Tasks.ValueTask`1.get_IsCompleted() +0 Npgsql.<<Open>g__OpenLong|0>d.MoveNext() +2701 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Npgsql.NpgsqlConnection.Open() +56

Further technical details

Npgsql version: 4.0.3 PostgreSQL version:9.6 Operating system: Azure Database for PostgreSQL server

Other details about my project setup: Running on azure app-service with full framework. Same error on local and dev slot in azure Looks the same as #2049 but should be fixed.

Regards

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bhoppenotcommented, Oct 19, 2018

For anyone having the same problem, resolved adding those lines in all .csproj files for all projects using npgsql (directly or via reference) :

<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath> </Reference>

Regards

0reactions
mltcommented, Oct 22, 2019

Apparently this is tracked by #2677

Read more comments on GitHub >

github_iconTop Results From Across the Web

unit testing - Weird Assembly.Load error trying to ...
I'm trying to compile an assembly from my code with C# code provider. When I access the compiled assembly with compilerResult.CompiledAssembly, ...
Read more >
Best Practices for Assembly Loading - .NET Framework
Explore best practices for assembly loading in .NET. Avoid problems of type identity that can lead to invalid casts, missing methods, ...
Read more >
How to resolve “Could not load file or assembly … or one of its ...
The Application base is location from executable is run. Then coming to question why error of assembly cannot be loaded? It is failing...
Read more >
When starting 3ds Max, a Plug-in Assembly Load Error ...
"Plug-in Assembly Load Error. The assembly "Autodesk.Max.Wrappers.dll" encountered an error while loading." when starting 3ds Max · Solution:.
Read more >
Could 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...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found