Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Self Updating Application #$%@

Self Updating Application #$%@

Scheduled Pinned Locked Moved C#
csharphardwarehelpquestionannouncement
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve Messer
    wrote on last edited by
    #1

    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?

    C P 2 Replies Last reply
    0
    • S Steve Messer

      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?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      S 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        S Offline
        S Offline
        Steve Messer
        wrote on last edited by
        #3

        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'."}

        C 1 Reply Last reply
        0
        • S Steve Messer

          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'."}

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          S 1 Reply Last reply
          0
          • S Steve Messer

            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?

            P Offline
            P Offline
            Patrick Etc
            wrote on last edited by
            #5

            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

            S 2 Replies Last reply
            0
            • C Christian Graus

              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 )

              S Offline
              S Offline
              Steve Messer
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • P Patrick Etc

                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

                S Offline
                S Offline
                Steve Messer
                wrote on last edited by
                #7

                Interesting, thanks I will look into your suggestions.

                1 Reply Last reply
                0
                • P Patrick Etc

                  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

                  S Offline
                  S Offline
                  Steve Messer
                  wrote on last edited by
                  #8

                  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.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups