'Npgsql.PoolManager' 的类型初始值设定项抛出异常
The type initializer for 'Npgsql.PoolManager' threw an exception
仅在 window 7 上获得此异常 "The type initializer for 'Npgsql.PoolManager' threw an exception."。
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)
{}
注意:相同的代码在 window 10 上运行良好。
运行 这个函数来自 installsheild 设置。请帮忙
我通过使用最新版本更新 System.ValueTuple.dll 解决了我的问题。问题出在 Npgsql.dll 和 System.ValueTuple.dll 之间的不兼容性。
我认为,如果我们添加了来自 nuget 的引用,问题就不会首先出现。
但奇怪的是它只出现在 window 7 或 32 位机器上。
仅在 window 7 上获得此异常 "The type initializer for 'Npgsql.PoolManager' threw an exception."。
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)
{}
注意:相同的代码在 window 10 上运行良好。 运行 这个函数来自 installsheild 设置。请帮忙
我通过使用最新版本更新 System.ValueTuple.dll 解决了我的问题。问题出在 Npgsql.dll 和 System.ValueTuple.dll 之间的不兼容性。
我认为,如果我们添加了来自 nuget 的引用,问题就不会首先出现。 但奇怪的是它只出现在 window 7 或 32 位机器上。