应用程序配置连接字符串未针对服务进行更新
App Config Connection String Not Updating For Service
我创建了一个带有 app.config 的网络服务,它保存着我的连接字符串。一切都按预期完美运行,除了当我将连接字符串更改为指向新的 table 时,服务将继续指向旧地址(即使我关闭服务)。
到目前为止,我找到的解决此问题的唯一方法是重建解决方案。
谁能想到为什么连接字符串只在我重建时更新?
()
private const string ConnectionStringName = "ConnectionString";
private readonly string _connectionString;
private readonly Logger _logger;
public AX2012DataPassing()
{
#if DEBUG
Thread.Sleep(10000);
#endif
InitializeComponent();
_logger = LogManager.GetCurrentClassLogger();
_logger.Info("Attempting to initialize connection string" + ConnectionStringName);
try
{
_connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString;
//// Test connection established, will throw error if does not
GetConfigValue(string.Empty);
_logger.Info("Connection String " + ConnectionStringName + " initialized");
}
catch (Exception e)
{
_logger.Info("Connection String " + ConnectionStringName + " failed to initialize");
_logger.Fatal("Connection String " + ConnectionStringName + " failed to initialize:" + e.Message);
return;
}
尝试重置 IIS,因为连接字符串可能被缓存。
我创建了一个带有 app.config 的网络服务,它保存着我的连接字符串。一切都按预期完美运行,除了当我将连接字符串更改为指向新的 table 时,服务将继续指向旧地址(即使我关闭服务)。
到目前为止,我找到的解决此问题的唯一方法是重建解决方案。
谁能想到为什么连接字符串只在我重建时更新?
()
private const string ConnectionStringName = "ConnectionString";
private readonly string _connectionString;
private readonly Logger _logger;
public AX2012DataPassing()
{
#if DEBUG
Thread.Sleep(10000);
#endif
InitializeComponent();
_logger = LogManager.GetCurrentClassLogger();
_logger.Info("Attempting to initialize connection string" + ConnectionStringName);
try
{
_connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString;
//// Test connection established, will throw error if does not
GetConfigValue(string.Empty);
_logger.Info("Connection String " + ConnectionStringName + " initialized");
}
catch (Exception e)
{
_logger.Info("Connection String " + ConnectionStringName + " failed to initialize");
_logger.Fatal("Connection String " + ConnectionStringName + " failed to initialize:" + e.Message);
return;
}
尝试重置 IIS,因为连接字符串可能被缓存。