c# - VS2010 on Win7, installer class within a setup is not called -


it installer class within setupproject, wich within winform project. till did hav errro message, not called. runinstallerattribute setted on true.

the thing wich left "main void", cant put it, cause neede winformproject.

here entire code:

using system; using system.collections; using system.diagnostics; using system.componentmodel; using system.configuration.install; using system.security.accesscontrol; using system.security.principal; using system.io; using system.windows.forms; using system.text; using system.threading;   [runinstaller(true)] partial class myinstaller : installer {      public myinstaller()     {               messagebox.show("myinstaller");         initializecomponent();     }       #region "onafter"       protected override void onafterinstall(idictionary savedstate)     {          base.onafterinstall(savedstate);     }       protected override void onafterrollback(idictionary savedstate)     {          base.onafterrollback(savedstate);     }       protected override void onafteruninstall(idictionary savedstate)     {          base.onafteruninstall(savedstate);     }     #endregion      #region "onbefore"       protected override void onbeforeinstall(idictionary savedstate)     {         base.onbeforeinstall(savedstate);     }       protected override void onbeforerollback(idictionary savedstate)     {          base.onbeforerollback(savedstate);     }       protected override void onbeforeuninstall(idictionary savedstate)     {          base.onbeforeuninstall(savedstate);     }     #endregion      #region "oncommitt"      protected override void oncommitted(idictionary savedstate)     {          base.oncommitted(savedstate);     }       protected override void oncommitting(idictionary savedstate)     {          base.oncommitting(savedstate);     }     #endregion      #region "rollback"     public override void rollback(idictionary savedstate)     {         base.rollback(savedstate);         try         {             string filename = savedstate["myexe"].tostring();             //msgbox("rollback ..." & filename)             if (file.exists(filename))             {                 file.delete(filename);             }         }           catch (installexception ex)         {              messagebox.show("uninstall" + ex.tostring());         }          catch (exception ex)         {             messagebox.show("uninstall" + ex.tostring());         }     }      #endregion      #region "uninstall"        public override void uninstall(idictionary savedstate)     {         try         {             string filename = savedstate["myexe"].tostring();              if (file.exists(filename))             {                 file.delete(filename);             }              base.uninstall(savedstate);          }         catch (installexception ex)         {             messagebox.show("uninstall" + ex.tostring());         }          catch (exception ex)         {             messagebox.show("uninstall" + ex.tostring());         }       }      #endregion      #region "install"     public override void install(idictionary savedstate)     {         messagebox.show("install  ");         string strtargetpath = path.combine(environment.getfolderpath(environment.specialfolder.commonapplicationdata), "mytest");               savedstate.add("myexe", strtargetpath);                    base.install(savedstate);      }     #endregion      #region "commit"        public override void commit(idictionary savedstate)     {           string strpath = "";          try         {               strpath = environment.getfolderpath(environment.specialfolder.commonapplicationdata);             strpath = path.combine(strpath, "mytest\\myapp.exe");                        using (process process = new process())             {                 process.startinfo.filename = "myapp.exe";                 process.startinfo.arguments = strpath;                 process.startinfo.useshellexecute = false;                 process.startinfo.redirectstandardoutput = true;                 process.startinfo.redirectstandarderror = true;                  stringbuilder output = new stringbuilder();                 stringbuilder error = new stringbuilder();                  using (autoresetevent outputwaithandle = new autoresetevent(false))                 using (autoresetevent errorwaithandle = new autoresetevent(false))                 {                     process.outputdatareceived += (sender, e) =>                     {                         if (e.data == null)                         {                             outputwaithandle.set();                         }                         else                         {                             output.appendline(e.data);                         }                     };                     process.errordatareceived += (sender, e) =>                     {                         if (e.data == null)                         {                             errorwaithandle.set();                         }                         else                         {                             error.appendline(e.data);                         }                     };                      process.start();                      process.beginoutputreadline();                     process.beginerrorreadline();                      if (process.waitforexit(1000) &&                         outputwaithandle.waitone(1000) &&                         errorwaithandle.waitone(1000))                     {                         // process completed. check process.exitcode here.                     }                     else                     {                         // timed out.                     }                 }             }          }          catch (exception ex)         {             messagebox.show("commit  " + ex.tostring());             application.exit();                   }      }       #endregion  } 

the reason did not add assembly custom action in setup project, since didn't mention doing so.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -