连续处理参数不再是 supported.NPGSQL

The ContinuousProcessing parameter is no longer supported.NPGSQL

我刚刚将我的 npgsql 从 2.5.5 升级到 3.1.1,我收到了这个运行时错误。

我的 DbConnection class

 public static string ServerConnectionString()
    {
        var connectionStringBuilder = new NpgsqlConnectionStringBuilder
        {
            Host = ConfigurationManager.AppSettings["Server"],
            Username = ConfigurationManager.AppSettings["UserId"],
            Database = "postgres",
            Password = ConfigurationManager.AppSettings["Password"],
            CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeout"]),
            ApplicationName = EverestEnums.ConnectionApplicationName.EverestServerChecker.ToString(),
            //  MaxPoolSize = 200,
            //   SyncNotification = true,
            KeepAlive = 1,
            ConnectionLifeTime = 1,
          //  MinPoolSize = 1,
            Pooling = false
        };
        return connectionStringBuilder.ConnectionString;
    }

堆栈跟踪

[NotSupportedException: The ContinuousProcessing parameter is no longer supported. Please see http://www.npgsql.org/doc/3.1/migration.html]

Npgsql.NpgsqlConnectionStringBuilder.set_ConnectionLifeTime(Int32 值) +62 Everest.Net.DatabaseLayer.DBFactory.DbConnection.ServerConnectionString() 在 E:\Everest_PES\Everest.Net.DatabaseLayer\DBFactory\DBConnection.cs:13 Everest.Net.DatabaseLayer.DBFactory.DBOperations.IsServerAvailable() 在 E:\Everest_PES\Everest.Net.DatabaseLayer\DBFactory\DBOperations.cs:216 Everest.Net.DatabaseLayer.DBFactory.ServerConnectivity.IsDbServerAvailable() 在 E:\Everest_PES\Everest.Net.DatabaseLayer\DBFactory\ServerConnectivity.cs:7 Everest.Net.BusinessLayer.DBFactory.ServerConnectivity.IsDbServerAvailable() 在 E:\Everest_PES\Everest.Net.BusinessLayer\DBFactory\ServerConnectivity.cs:12 Everest.Net.Web.Global.Application_Start(Object sender, EventArgs e) in E:\Everest_PES\Everest.Net.Web\Global.asax.cs:15

[HttpException (0x80004005): 不再支持 ContinuousProcessing 参数。请参阅 http://www.npgsql.org/doc/3.1/migration.html] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext 上下文,HttpApplication 应用程序)+544 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +186 System.Web.HttpApplication.InitSpecial(HttpApplicationState 状态、MethodInfo[] 处理程序、IntPtr appContext、HttpContext 上下文)+172 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext 上下文) +402 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343

[HttpException (0x80004005): 不再支持 ContinuousProcessing 参数。请参阅 http://www.npgsql.org/doc/3.1/migration.html] System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +579 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文) +112 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext 上下文) +712

因为它工作正常 before.But 连接有一些问题 pooling.And 然后我升级了 npgsql 和这个 rumtime error.Any 帮助。

当您在 NpgsqlConnectionStringBuilder 上获取或设置 ConnectionLifeTime 属性 时,似乎抛出了异常。 属性 已过时,现在由连接空闲生命周期 属性 取代(请参阅 http://www.npgsql.org/doc/migration.html)。尝试改用它:

 public static string ServerConnectionString()
    {
        var connectionStringBuilder = new NpgsqlConnectionStringBuilder
        {
            Host = ConfigurationManager.AppSettings["Server"],
            Username = ConfigurationManager.AppSettings["UserId"],
            Database = "postgres",
            Password = ConfigurationManager.AppSettings["Password"],
            CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeout"]),
            ApplicationName = EverestEnums.ConnectionApplicationName.EverestServerChecker.ToString(),
            //  MaxPoolSize = 200,
            //   SyncNotification = true,
            KeepAlive = 1,
            ConnectionIdleLifetime = 1,
          //  MinPoolSize = 1,
            Pooling = false
        };
        return connectionStringBuilder.ConnectionString;
    }