我创建了一个带有app.config的webservice,它持有我的连接字符串。除了更改连接字符串以指向新表之外,服务将继续指向旧地址(即使我关闭服务),一切都完美无缺。
到目前为止,我找到的唯一方法是重建解决方案。
任何人都可以想到为什么在我重建时只更新连接字符串?
()
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;
}
答案 0 :(得分:1)
尝试重置IIS,因为可以缓存连接字符串。