简体   繁体   中英

Npgsql assembly error in Classlibrary output type

I have to connect to postgresql via Npgsql provider in nunit test, but I'm facing an assembly error:

System.IO.FileLoadException : Could not load file or assembly 'Npgsql, Version=4.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045) at PostgresTest.Testink.ConTest()

If I change application output type to Console Application everything works correctly.

  1. I've checked dll in bin path - Npgsql.dll is in bin path
  2. I've tried different net versions(>=4.5.1)
  3. I've tried to use xunit - the same problem

Guys, any ideas what am I doing improperly?

[Test]
public void ConTest()
    {
        var connString = "Host=127.0.0.1;Username=root;Password=pwd;Database=database";

        using (var conn = new NpgsqlConnection(connString))
        {
            conn.Open();             

        }
     }

This was an issue with the building of 4.0.1 ( see issue ) and will be fixed in 4.0.2 (to be released in a few days). In the meantime stick with 4.0.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM