Reputation: 6468
I do refactoring legacy WinForms app. Now it is NET Framework 4.8 based app working with SQL Server and PostgreSQL.
But during the execution this code:
SqlConnection connect = new SqlConnection();
connect.ConnectionString = connectionString; // <-- here error happens
I receive the error:
------------ System.IO.FileLoadException HResult=0x80131040 Message=Could not load file or assembly 'System.Memory, Version=4.5.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source=Microsoft.Data.SqlClient StackTrace: at Microsoft.Data.LocalDBAPI.GetLocalDbInstanceNameFromServerName(String serverName) at Microsoft.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
Inner Exception 1: FileLoadException: Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
It occurs after I have added Npgsql 7.0.4 Nuget package.
How to fix it?
The simplified code:
//Installed Nuget System.Memory (fresh dll: 4.5.5.0)
// using Microsoft.Data.SqlClient
SqlConnection connect = new SqlConnection(connectionString);
and the message:
System.IO.FileLoadException: 'Could not load file or assembly 'System.Memory, Version=4.5.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
Upvotes: 0
Views: 392