Self Updating Application #$%@
-
I am trying to create a self updating application. I am sure that you have heard of .Net Reflector. It is a single exe which has the ability to update it self. Oddly enough it you try to use Reflector on itself it has be ofuscated. So, I can't see what he has done. Here is how it works. 1. You start up the app and it detects that it needs an update. 2. It appears to shut itself down, download the updated exe and then restarts it. It you watch the process list you will see that during the update process he spawns (starts...) a process called tmp6E.exe, which I am guessing does the work. I have coded up a solution but it doesn't work correctly. 1. I embedded an update.exe program in my main app which does the updating, which works fine. 2. I have tried not using it embedded but I still have the same problem. How do you start/spawn a process and then shut down the parent (calling app) so that you can over write it?
-
I am trying to create a self updating application. I am sure that you have heard of .Net Reflector. It is a single exe which has the ability to update it self. Oddly enough it you try to use Reflector on itself it has be ofuscated. So, I can't see what he has done. Here is how it works. 1. You start up the app and it detects that it needs an update. 2. It appears to shut itself down, download the updated exe and then restarts it. It you watch the process list you will see that during the update process he spawns (starts...) a process called tmp6E.exe, which I am guessing does the work. I have coded up a solution but it doesn't work correctly. 1. I embedded an update.exe program in my main app which does the updating, which works fine. 2. I have tried not using it embedded but I still have the same problem. How do you start/spawn a process and then shut down the parent (calling app) so that you can over write it?
Probably with Process.Start, I'd imagine a call to Procss.Start followed by this.Close() would not close the spawned process.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Probably with Process.Start, I'd imagine a call to Procss.Start followed by this.Close() would not close the spawned process.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
That's what I tried first. But it doesn't work.
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); <<<---- exception here. }
I get the following exception {"Cannot access a disposed object.\r\nObject name: 'Form1'."} -
That's what I tried first. But it doesn't work.
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); <<<---- exception here. }
I get the following exception {"Cannot access a disposed object.\r\nObject name: 'Form1'."}When do you get this exception ? What do you do to restart Main, or do you just get it when you run the app the second time ? If so, how do you run it ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I am trying to create a self updating application. I am sure that you have heard of .Net Reflector. It is a single exe which has the ability to update it self. Oddly enough it you try to use Reflector on itself it has be ofuscated. So, I can't see what he has done. Here is how it works. 1. You start up the app and it detects that it needs an update. 2. It appears to shut itself down, download the updated exe and then restarts it. It you watch the process list you will see that during the update process he spawns (starts...) a process called tmp6E.exe, which I am guessing does the work. I have coded up a solution but it doesn't work correctly. 1. I embedded an update.exe program in my main app which does the updating, which works fine. 2. I have tried not using it embedded but I still have the same problem. How do you start/spawn a process and then shut down the parent (calling app) so that you can over write it?
The easiest thing to do would be to load your assembly (assemblies) in a shadow cache - this is a little known feature of .NET that copies your assemblies to a temporary directory before executing them. This is done explicitly for the purpose you are asking - software updates - but also for some other, very obscure security reasons that I don't fully understand myself. At any rate, I first learned of the approach from the Morrison Schartz plugin manager, so you might download their plugin source code and take a look. There are also several articles here on Code Project that use a strikingly similar approach, so they would be good to look at (search for "application auto-update"). For the Morrison Schwartz approach, go here: http://www.ms-inc.net/dotnet.aspx?ProductID=Plugins
-
When do you get this exception ? What do you do to restart Main, or do you just get it when you run the app the second time ? If so, how do you run it ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Okay, I found part of my problem. First let me explain what I am trying to do. I currently have two exe's. 1. MainApp.exe (has two forms the main form and an update form) 2. Update.exe When MainApp.exe starts up it downloads a file from one of my web pages (version.txt) it currently contains 2.0.0.0. I then compare my current version which is 1.0.0.0 and if the version on the server is larger than my current version I create an instance of my update form which says "There is an update available do you want to automatically update?". If you click no I just close the update form and then the main form is shown. If you click yes, I close the update form and I start the update.exe as a process. Then I want to exit out of the MainApp.exe and let update.exe download the update replacing the current out of date one. My first problem is that I was doing this logic inside the MainForm constructor. If you attempt to call this.Close() the form has even finished creating itself and thus my problem. My next problem seems that I am in a continuous loop calling my update form in the MainApp over and over again.
-
The easiest thing to do would be to load your assembly (assemblies) in a shadow cache - this is a little known feature of .NET that copies your assemblies to a temporary directory before executing them. This is done explicitly for the purpose you are asking - software updates - but also for some other, very obscure security reasons that I don't fully understand myself. At any rate, I first learned of the approach from the Morrison Schartz plugin manager, so you might download their plugin source code and take a look. There are also several articles here on Code Project that use a strikingly similar approach, so they would be good to look at (search for "application auto-update"). For the Morrison Schwartz approach, go here: http://www.ms-inc.net/dotnet.aspx?ProductID=Plugins
Interesting, thanks I will look into your suggestions.
-
The easiest thing to do would be to load your assembly (assemblies) in a shadow cache - this is a little known feature of .NET that copies your assemblies to a temporary directory before executing them. This is done explicitly for the purpose you are asking - software updates - but also for some other, very obscure security reasons that I don't fully understand myself. At any rate, I first learned of the approach from the Morrison Schartz plugin manager, so you might download their plugin source code and take a look. There are also several articles here on Code Project that use a strikingly similar approach, so they would be good to look at (search for "application auto-update"). For the Morrison Schwartz approach, go here: http://www.ms-inc.net/dotnet.aspx?ProductID=Plugins
Sounds easy but, I am having troubles. I can't seem to get this to work. How do you load an exe in the shadow cache? As in the case of .net Reflector I am trying to solve this using a single exe.