- Have created a installer class, which is being inherited from my web setup project
- Override the Install() method by using this piece of code(A).
Been trying to pass parameter values from the web setup project installer to my custom app setting key, but keep getting the following error.
Here is my custom installer class,
[RunInstaller(true)]
public partial class Installer2 : System.Configuration.Install.Installer
{
public Installer2()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
//base.Install(stateSaver);
try
{
// In order to get the value from the textBox named 'EDITA1' I needed to add the line:
// '/PathValue = [EDITA1]' to the CustomActionData property of the CustomAction We added.
string userName = Context.Parameters["USERNAME"];
string password = Context.Parameters["PASSWORD"];
string server = Context.Parameters["SSERVER"];
MessageBox.Show(userName);
MessageBox.Show(password);
string path = Application.ExecutablePath;
Configuration config = ConfigurationManager.OpenExeConfiguration(path);
//config.AppSettings.Settings.Add("userName", userName);
//config.AppSettings.Settings.Add("password", password);
//config.AppSettings.Settings.Add("foderPath", folderPath);
config.AppSettings.Settings["Username"].Value = userName;
config.AppSettings.Settings["Password"].Value = password;
config.AppSettings.Settings["Server"].Value = server;
config.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection("appSettings");
}
catch (FormatException e)
{
string s = e.Message;
throw e;
}
}
}
And here is my textbox properties in my web setup project,
And the appSettings section,
Aucun commentaire:
Enregistrer un commentaire