Npgsql assembly error in Classlibrary output type

1

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();             

        }
     }
c#
.net
nunit
npgsql
asked on Stack Overflow Jul 5, 2018 by Pavel Galich • edited Jul 5, 2018 by prl

1 Answer

3

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.

answered on Stack Overflow Jul 5, 2018 by Shay Rojansky

User contributions licensed under CC BY-SA 3.0