You are viewing our Forum Archives. To view or take place in current topics click here.
[Visual Studio] C# auto updater? +REP
Posted:
[Visual Studio] C# auto updater? +REPPosted:
Status: Offline
Joined: Jun 06, 201311Year Member
Posts: 927
Reputation Power: 79
Hey guys, im looking for a way to add a auto updater to my program? I am not entirely sure on how to do this
but if you guys have any easy tutorials or solutions could you please post them! I will +REP 35 twice for help. Thank you!
but if you guys have any easy tutorials or solutions could you please post them! I will +REP 35 twice for help. Thank you!
#2. Posted:
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
It's actually quite easy. The way you have to do it is split your program up into a starting excecutable and then a containing library. Essentially you put your update code in the starter and it will download a new DLL and remove and replace the old one. ill have to dig up the code for it but its actually pretty simple
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
Ok, so im assuming you using forms and whatnot for this but it can easily be adapted actually. So in Visual studio create a new Console application. This will be the base starter for the game. In the solution explorer click on the solution NOT the console application and right click then click Add>New Project and click on Windows form application and create it. Now in the new forms project click on properties and set the output type to Class Library. This way when you build the application it will create the starter as a .exe and the form as a .dll. This way you can develop new dlls and have them updated. Here's the code to actually get it to work.
From there you would do your update checking from the form, if theres an update you download the new version and restart the program.
ALSO! if you dont want the console to be sticking around in the background, in the Console application settings, set the Output type to Windows Application, it will then be hidden, otherwise that lovely black console will be there the whole time your application is running
If you want a full example I can write one up and put it on media fire for you. It'll be easier to see how the code works and it'll take me less time than it would to whip it up in the TTG editor ;P Just send me a pm if you want a more full example and ill work on it anyways haha
//in the console application you would put your update logic so something like this
//This goes in the main function of the console program, obviously replace the names with your own
//you will have problems with the start line until you do the edits below this
//Dont forget your usings! you also need to add using System.IO;
if(File.Exists("yourDLLNew.dll"))
{
File.Delete("yourDLLOld.dll");
File.Copy("yourDLL.dll","yourDLLOld.dll");//always keep backups!
File.Delete("yourDLL.dll");
File.Copy("yourDLLNew.dll", "yourDLL.dll");
File.Delete("yourDLLNew.dll");
WindowsFormsApplication1.Program.Main();//starts the form
}
else
{
WindowsFormsApplication1.Program.Main();//starts the form
}
//Now you need to edit the Program file in the WindowsFormsApplication1 project
//change
static class Program
//to
public static class Program
//and
static void Main()
//to
public static void Main()
From there you would do your update checking from the form, if theres an update you download the new version and restart the program.
ALSO! if you dont want the console to be sticking around in the background, in the Console application settings, set the Output type to Windows Application, it will then be hidden, otherwise that lovely black console will be there the whole time your application is running
If you want a full example I can write one up and put it on media fire for you. It'll be easier to see how the code works and it'll take me less time than it would to whip it up in the TTG editor ;P Just send me a pm if you want a more full example and ill work on it anyways haha
- 1useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Oct 31, 201014Year Member
Posts: 2,084
Reputation Power: 95
Status: Offline
Joined: Oct 31, 201014Year Member
Posts: 2,084
Reputation Power: 95
Like above, have a seperate updated program and have your main program check for an update, if there is one then have the main program start the updater, the updater would then kill the main program's process; once killed, it would delete the old files and download the new files (including the EXE), once downloaded. It would start the new EXE. I think modio does something like this.
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.