简体   繁体   English

Classlibrary输出类型中的Npgsql程序集错误

[英]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: 我必须在nunit测试中通过Npgsql提供程序连接到postgresql,但我面临一个程序集错误:

System.IO.FileLoadException : Could not load file or assembly 'Npgsql, Version=4.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its dependencies. System.IO.FileLoadException:无法加载文件或程序集'Npgsql,Version = 4.0.1.0,Culture = neutral,PublicKeyToken = 5d8b90d52f46fda7'或其依赖项之一。 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() (来自HRESULT的异常:0x80131045)在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 我在bin路径中检查了dll - Npgsql.dll在bin路径中
  2. I've tried different net versions(>=4.5.1) 我试过不同的网络版本(> = 4.5.1)
  3. I've tried to use xunit - the same problem 我试过用xunit - 同样的问题

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). 这是构建4.0.1( 参见问题 )的问题 ,将在4.0.2中修复(将在几天内发布)。 In the meantime stick with 4.0.0. 在此期间坚持使用4.0.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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