0
ユーザー接続文字列入力データを使用して、拡張インストーラ.MSIウィザードでweb.configファイルを作成しようとしています。web.configに保存して、追加の "config"拡張を追加します。
この結果、ファイルweb.config.config
には余分なconfig
が含まれていますが、どうして避けますか?
オープンまたは保存が正しくないと思いますか?
これはカスタムアクションです.MSIの中で、私はアドバンストインストーラから実行しましたが、それは私が思うような影響はありません。
[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
あなたは大歓迎です。お力になれて、嬉しいです :) –