Note that there are some explanatory texts on larger screens.

plurals
  1. POSimplified application updating in .NET
    primarykey
    data
    text
    <p>Automatically updating a desktop application seems to be a hard problem in .NET. There are a number of solutions, from microsoft's clickonce, to various open source and paid solutions. The pattern in all of these is:</p> <p>1 check remote server for version to run<br> 2 download the new version<br> 3 unpack to a temp folder<br> 4 start a shim process to replace the old files with the new after the app shuts down<br> 5 kill the running app so the shim process can begin working<br> 6 restart the main app </p> <p>This process seems to have a lot of moving parts and points of failure. However, you can write your application to be a simple loop that downloads and executes a remote dll. It seems this avoids a lot of the complexity involved in automatically updating your application, like user permissions, uac, antivirus programs, etc. </p> <p>It seems solid and futureproof to me. My app doesn't need lots of large support files, so is there a reason I shouldn't use this approach? Are there ways this can go terribly wrong? If so, how do these complexities compare to the complexities of other auto-updating solutions?</p> <p>for example:</p> <pre><code>Thread helper; int currentVersion=0; static void Main() { //dumb loop, functions as a loader while(true) { var remoteVersion = GetRemoteVersion(); if(remoteVersion &gt; currentVersion) { if(helper != null) { //kill thread gracefully :) } currentVersion = remoteVersion; byte[] bytes = GetRemoteDllAsByteArray(); var asm = Assembly.Load(bytes); var t = asm.GetType("a known type with a static method called Start()"); var mi = t.GetMethod("Start"); //run this on a helper thread outside the main loop: // the start method is the entry point to your application helper= new Thread(() =&gt; mi.Invoke(null,null)); helper.SetApartmentState(ApartmentState.STA); //for winforms/wpf helper.Start(); } Thread.Sleep(1 day);//only check for new versions once a day } } </code></pre> <p>The extra complexity in my example is you have to package all your dependencies as resources in the downloaded dll, but that can be set up as a build step, and it avoids messing with the user's filesystem. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload