0
我想要在用戶連接字符串輸入數據的高級安裝程序.MSI嚮導中創建一個web.config文件。保存到web.config,添加一個額外的「配置」擴展
爲什麼會產生web.config.config
文件帶有額外的config
,我該如何避免它?
我想我的打開或保存不正確?
這是一個自定義操作,在.MSI中,我從Advanced Installer運行,但它應該沒有任何影響,我認爲。
[CustomAction]
public static ActionResult EncryptConnStr(Session session)
{
try
{
var path = Path.Combine(@"C:\Users\radbyx\Documents", "web.config");
var connStr = BuildConnStr("foo", "foo", "foo", "foo");
Configuration config = ConfigurationManager.OpenExeConfiguration(path);
ConnectionStringsSection section = (ConnectionStringsSection)config.GetSection("connectionStrings");
section.ConnectionStrings.Add(new ConnectionStringSettings(GetConnectionStringName(), connStr));
// Encrypt
//section.SectionInformation.ProtectSection(ConnStrEncryptionKey);
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified, true);
return ActionResult.Success;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "Trace: " + ex.StackTrace, ex.Message);
throw;
}
}
哇它的作品,你是男人。應該很久以前問過了。再次是這裏最好的網站:) – radbyx
不客氣。樂於幫助 :) –