Pax Obi

Pax Obi

  • NA
  • 76
  • 1.2k

InstallerSetup.cs pass installation parameters in from1.cs

Jan 19 2018 12:50 AM
I have properly overwrite commit in InstallerSetup.cs I do not wish to write the user entered value to app.config but rather I want to pass the string Context.Parameters["TESTPARAMETER"]; to another class in form1.cs on load function. I tried string test = InstallerSetup.Context.Parameters["TESTPARAMETER"]; but getting InstallerSetup.Context is null . Please Help. 
 
InstallerSetup.cs
  1. public override void Commit(IDictionary savedState)  
  2. {  
  3. base.Commit(savedState);  
  4. try  
  5. {   
  6. SQLSERVERNAME = Context.Parameters["SQLSERVERNAME"];  
  7. HMSTENANTDB = Context.Parameters["HMSTENANTDB"];  
  8. SQLLOGIN = Context.Parameters["SQLLOGIN"];  
  9. SQLPASSWORD = Context.Parameters["SQLPASSWORD"];    
  10. }  
  11. catch (Exception e)  
  12. {  
  13. MessageBox.Show("Failed to update the application configuration file : " + e.Message);  
  14. base.Rollback(savedState);  
  15. }  
  16. }  
from1.cs
  1. InstallerSetup InsSetup = new InstallerSetup();  
  2. string Vsqlserver = InsSetup.Installers.Count.ToString();  
  3. string Vtenant = "";  
  4. if (InsSetup.Context != null)  
  5. {  
  6. Vtenant = InsSetup.Context.Parameters["HMSTENANTDB"];  
  7. }  
  8. else  
  9. {  
  10. Vtenant = "context is null";  
  11. }  

Attachment: InstallerSetup.rar

Answers (2)