获取此异常“‘Npgsql.PoolManager’的类型初始值设定项引发了异常。”仅在窗口 7 上。
public string ValidateDefaultInstancePostgreSqlServer()
{
string found = "0";
try
{
using (NpgsqlConnection postGresConnection = new NpgsqlConnection())
{
postGresConnection.ConnectionString = "Server=localhost;Port=5432;Database=postgres;User Id=postgres;Password=postgre123;Pooling=true;MinPoolSize=1;MaxPoolSize=100;Command Timeout=600;Timeout=600;";
using (NpgsqlCommand checkDBCommand = postGresConnection.CreateCommand())
{
postGresConnection.Open();
found = "1";
}
}
}
catch (Exception e)
{}
注意:相同的代码在窗口 10 上运行良好。 从 installsheld 设置运行此功能。请帮忙。
我通过使用最新版本更新 System.ValueTuple.dll 解决了我的问题。问题是 Npgsql.dll 和 System.ValueTuple.dll 之间不兼容。
我认为,如果我们添加来自 nuget 的引用,这个问题就不会排在第一位。 但奇怪的是它只出现在 Windows 7 或 32 位机器上。
将块包 System.Diagnostics.DiagnosticSource 从 6.0.0 更新到 8.0.0 对我有用