Assembly loading error
See original GitHub issueSteps 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:
- Created 5 years ago
- Comments:7 (2 by maintainers)
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
Apparently this is tracked by #2677