Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How can I implement automatic updating?

Go to solution Solved by lubblig,
5 hours ago, AluminiumTech said:

So would this work?

 



 
       private void checkForUpdate()
        {
            string insiderPreviewURL = "https://1drv.ms/t/s!Ar65S5uonmfNmPhZqSrE3JEbAGju2Q";
            string releaseURL;
            string version;
            version = Settings.App.Default.Version;
 
            WebClient web = new WebClient();
            string newVersion = web.DownloadString(insiderPreviewURL);
           
if (newVersion.Contains(Settings.App.Default.Version))
            {
                Form update = new UpdateAvailable();
                update.ShowDialog();
            }
[/Code]

Unsure, the code should likely work. That is very simple for you to test. What I'm unsure of is if the URL will change if the file is updated with new content. I don't think it will but it's a possibility. Also, now you are dependent on that this URL doesn't change. Which could happen, Microsoft may change what servers the file is stored on or something, giving you a new URL.

 

If you instead were to buy a domain, lets say "altech.com" or something, and point it to the cloud hosted file (https://1drv.ms/t/s!Ar65S5uonmfNmPhZqSrE3JEbAGju2Q). Then if the URL changes or in the unlikely scenario that Microsoft goes bankrupt or similar, you can easily just point the altech.com domain somewhere else and your users won't be affected.

 

I understand if you do not want to pay for hosting and that you may be unable to host from home (if you are however able to do that, apache on a linux server is actually rather simple to setup). But buying a domain is generally very cheap and it could really help you out in scenarios like this one, if the Onedrive URL were to change in the future for some reason, just point it to wherever it is now.

So, I have a program which has gained a bit of popularity.

 

I'd like to make it be able to automatically update when there are new updates.

 

I have experimented with IIS in the past.........

 

With the auto updater, I want to have 2 "branches" for users to be able to update from. One for Stable builds and the other for BETA builds.

 

Do I need to enable port forwarding? How can I easily make my C# program update when new versions are available?

 

Thanks :).

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill

iPhone 8 Plus (Mid 2019 to present)

Samaritan XTX (Early 2021 Upgrade - AMD Ryzen 9 3900XT (12C/24T)  (2021) , MSI X370 Gaming Pro Carbon, Corsair 32GB Vengeance LPX DDR4-2666 (2020) ,  Asus ROG Strix RX Vega 56 , Corsair RM850i PSU, Noctua NH-D15 CPU Cooler (2021), Samsung 860 EVO 500GB SSD, Seagate BarraCuda 6TB HDD (2020) , NZXT S340 Elite, Corsair ML 120 Pro, Corsair ML120 x2 (2021)

Link to post
Share on other sites

I'd make a web service that returns the current version number, and have the application periodically query that service. If there's a new version available, notify the user that they can download a new version, or download the update & install it automatically (I prefer the first, in the case of the user not wanting to upgrade at that time).

Link to post
Share on other sites
1 hour ago, HarryNyquist said:

I'd make a web service that returns the current version number, and have the application periodically query that service. If there's a new version available, notify the user that they can download a new version, or download the update & install it automatically (I prefer the first, in the case of the user not wanting to upgrade at that time).

but how would I set that up? Would I need to do port forwarding since I don't have my own domain?

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill

iPhone 8 Plus (Mid 2019 to present)

Samaritan XTX (Early 2021 Upgrade - AMD Ryzen 9 3900XT (12C/24T)  (2021) , MSI X370 Gaming Pro Carbon, Corsair 32GB Vengeance LPX DDR4-2666 (2020) ,  Asus ROG Strix RX Vega 56 , Corsair RM850i PSU, Noctua NH-D15 CPU Cooler (2021), Samsung 860 EVO 500GB SSD, Seagate BarraCuda 6TB HDD (2020) , NZXT S340 Elite, Corsair ML 120 Pro, Corsair ML120 x2 (2021)

Link to post
Share on other sites
7 minutes ago, AluminiumTech said:

but how would I set that up? Would I need to do port forwarding since I don't have my own domain?

Honestly, just having a simple html file with just the version number would work, you'd just have to retrieve that page and read the text on it, which should be only the version number. How you do that is up to you.

 

As for port forwarding, I don't know your setup and I can't help you there. When I set up my personal server I had to forward every port I had intended to use (SSH, HTTPS, etc). I don't know if you'll have to do the same.

 

I would also strongly recommend getting a domain name. They're very cheap and useful to have.

Link to post
Share on other sites

I would agree with @HarryNyquist that not having it auto update but rather check for updates and if the user wants to, direct the user to the download page.

I've done a similar thing in the past and the code I used was something like this:

WebClient web = new WebClient();
//Download the .txt file and save it to a string
string update = web.DownloadString("http://example.com/latest_stable_version.txt");

//Compare downloaded string with the applications product version
if (update.Contains(Application.ProductVersion))
	{
		//If the downloaded string contains the current product version of the .exe, the file is the latest available
    }
else
	{
      	//Run code to tell user a new update is available. For example:
      	MessageBox.Show("A new version is available (" + update + "). Go to http://example.com/download for the latest version.");
    }

Note, you'll have to import the System.Net namespace.

using System.Net;

 

The file would look like this:

1.0.0.0

as this is how the versioning looks in Windows.

 

The actual Application.Product version can be accessed via "Solution Explorer", Double click "Properties", click "Assembly Information" and edit the version.

 

 

How you would actually host the .txt file I'm not sure of. You could make a free apache server at home and open port 80 and use something like noip to get a static url. But the optimal thing is likely to buy a domain. It's possible that you could upload the file onto a cloud hosting service. You'd need to make sure you have a static URL to it though (even after it's been updated with new information).

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to post
Share on other sites

I don't care if I use something everyday, as soon as it auto updates without my knowledge it gets deleted. I would also advise going with the notify option, and have a way in you program to check either every day, week, or whatever depending on what the user wants.

Link to post
Share on other sites

The issue isn't so much the check but usually the update itself. You see a program can't replace itself while its running, so you need a separate process that is not overwritten to do the updating of the primary program and to do the updates when shutdown. This is the reason Firefox etc have those daemon processes running. All they do is pull down the version and check against the latest but they also await the program shutting down and replacing it.

 

Personally I think this ought to be in windows and its getting a bit ridiculous that every program has its own update system.

Link to post
Share on other sites
1 hour ago, jimistephen said:

I don't care if I use something everyday, as soon as it auto updates without my knowledge it gets deleted. I would also advise going with the notify option, and have a way in you program to check either every day, week, or whatever depending on what the user wants.

 

It is annoying how often applications break something with newer versions. though if i have the option to auto update that's ok. I don't mind things like my steam games auto updating.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

I apologize if this is completely unreasonable as I'm not entirely sure how the process works or what your situation is, but would it be possible to have it in the Windows Store and for it to update automatically along with other things from there or with Windows update itself?

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to post
Share on other sites
3 hours ago, Ryan_Vickers said:

I apologize if this is completely unreasonable as I'm not entirely sure how the process works or what your situation is, but would it be possible to have it in the Windows Store and for it to update automatically along with other things from there or with Windows update itself?

This isn't a UWP app though............ And  not all of the intended target audience runs Windows 10.

 

7 hours ago, lubblig said:

I would agree with @HarryNyquist that not having it auto update but rather check for updates and if the user wants to, direct the user to the download page.

I've done a similar thing in the past and the code I used was something like this:


WebClient web = new WebClient();
//Download the .txt file and save it to a string
string update = web.DownloadString("http://example.com/latest_stable_version.txt");

//Compare downloaded string with the applications product version
if (update.Contains(Application.ProductVersion))
	{
		//If the downloaded string contains the current product version of the .exe, the file is the latest available
    }
else
	{
      	//Run code to tell user a new update is available. For example:
      	MessageBox.Show("A new version is available (" + update + "). Go to http://example.com/download for the latest version.");
    }

Note, you'll have to import the System.Net namespace.


using System.Net;

 

The file would look like this:


1.0.0.0

as this is how the versioning looks in Windows.

 

The actual Application.Product version can be accessed via "Solution Explorer", Double click "Properties", click "Assembly Information" and edit the version.

 

 

How you would actually host the .txt file I'm not sure of. You could make a free apache server at home and open port 80 and use something like noip to get a static url. But the optimal thing is likely to buy a domain. It's possible that you could upload the file onto a cloud hosting service. You'd need to make sure you have a static URL to it though (even after it's been updated with new information).

As a temporary solution, could I use the static IP onto Cloud Storage?

 

I might try this out later.......

 

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill

iPhone 8 Plus (Mid 2019 to present)

Samaritan XTX (Early 2021 Upgrade - AMD Ryzen 9 3900XT (12C/24T)  (2021) , MSI X370 Gaming Pro Carbon, Corsair 32GB Vengeance LPX DDR4-2666 (2020) ,  Asus ROG Strix RX Vega 56 , Corsair RM850i PSU, Noctua NH-D15 CPU Cooler (2021), Samsung 860 EVO 500GB SSD, Seagate BarraCuda 6TB HDD (2020) , NZXT S340 Elite, Corsair ML 120 Pro, Corsair ML120 x2 (2021)

Link to post
Share on other sites
6 minutes ago, AluminiumTech said:

This isn't a UWP app though............ And  not all of the intended target audience runs Windows 10.

 

Ah ok.  I did warn you I didn't really know if that was an option or not :P 

 

Honestly, my advice would be to not worry about it.  If you do add something, make it something simple that checks your site to see if there is an update and then prompt he user to visit it.  Trying to build an actual automatic update system could have issues.  You'll have to be careful that it doesn't introduce security holes for one thing...

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to post
Share on other sites
19 minutes ago, Ryan_Vickers said:

Ah ok.  I did warn you I didn't really know if that was an option or not :P 

 

Honestly, my advice would be to not worry about it.  If you do add something, make it something simple that checks your site to see if there is an update and then prompt he user to visit it.  Trying to build an actual automatic update system could have issues.  You'll have to be careful that it doesn't introduce security holes for one thing...

I'll just do something which tells you there's a new update. Or I could maybe use ClickOnce.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill

iPhone 8 Plus (Mid 2019 to present)

Samaritan XTX (Early 2021 Upgrade - AMD Ryzen 9 3900XT (12C/24T)  (2021) , MSI X370 Gaming Pro Carbon, Corsair 32GB Vengeance LPX DDR4-2666 (2020) ,  Asus ROG Strix RX Vega 56 , Corsair RM850i PSU, Noctua NH-D15 CPU Cooler (2021), Samsung 860 EVO 500GB SSD, Seagate BarraCuda 6TB HDD (2020) , NZXT S340 Elite, Corsair ML 120 Pro, Corsair ML120 x2 (2021)

Link to post
Share on other sites
11 hours ago, lubblig said:

I would agree with @HarryNyquist that not having it auto update but rather check for updates and if the user wants to, direct the user to the download page.

I've done a similar thing in the past and the code I used was something like this:


WebClient web = new WebClient();
//Download the .txt file and save it to a string
string update = web.DownloadString("http://example.com/latest_stable_version.txt");

//Compare downloaded string with the applications product version
if (update.Contains(Application.ProductVersion))
	{
		//If the downloaded string contains the current product version of the .exe, the file is the latest available
    }
else
	{
      	//Run code to tell user a new update is available. For example:
      	MessageBox.Show("A new version is available (" + update + "). Go to http://example.com/download for the latest version.");
    }

Note, you'll have to import the System.Net namespace.


using System.Net;

 

The file would look like this:


1.0.0.0

as this is how the versioning looks in Windows.

 

The actual Application.Product version can be accessed via "Solution Explorer", Double click "Properties", click "Assembly Information" and edit the version.

 

 

How you would actually host the .txt file I'm not sure of. You could make a free apache server at home and open port 80 and use something like noip to get a static url. But the optimal thing is likely to buy a domain. It's possible that you could upload the file onto a cloud hosting service. You'd need to make sure you have a static URL to it though (even after it's been updated with new information).

So would this work?



       private void checkForUpdate()
        {
            string insiderPreviewURL = "https://1drv.ms/t/s!Ar65S5uonmfNmPhZqSrE3JEbAGju2Q";
            string releaseURL;
            string version;
            version = Settings.App.Default.Version;
 
            WebClient web = new WebClient();
            string newVersion = web.DownloadString(insiderPreviewURL);
           
if (newVersion.Contains(Settings.App.Default.Version))
            {
                Form update = new UpdateAvailable();
                update.ShowDialog();
            }
[/Code]

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill

iPhone 8 Plus (Mid 2019 to present)

Samaritan XTX (Early 2021 Upgrade - AMD Ryzen 9 3900XT (12C/24T)  (2021) , MSI X370 Gaming Pro Carbon, Corsair 32GB Vengeance LPX DDR4-2666 (2020) ,  Asus ROG Strix RX Vega 56 , Corsair RM850i PSU, Noctua NH-D15 CPU Cooler (2021), Samsung 860 EVO 500GB SSD, Seagate BarraCuda 6TB HDD (2020) , NZXT S340 Elite, Corsair ML 120 Pro, Corsair ML120 x2 (2021)

Link to post
Share on other sites
5 hours ago, AluminiumTech said:

So would this work?

 



 
       private void checkForUpdate()
        {
            string insiderPreviewURL = "https://1drv.ms/t/s!Ar65S5uonmfNmPhZqSrE3JEbAGju2Q";
            string releaseURL;
            string version;
            version = Settings.App.Default.Version;
 
            WebClient web = new WebClient();
            string newVersion = web.DownloadString(insiderPreviewURL);
           
if (newVersion.Contains(Settings.App.Default.Version))
            {
                Form update = new UpdateAvailable();
                update.ShowDialog();
            }
[/Code]

Unsure, the code should likely work. That is very simple for you to test. What I'm unsure of is if the URL will change if the file is updated with new content. I don't think it will but it's a possibility. Also, now you are dependent on that this URL doesn't change. Which could happen, Microsoft may change what servers the file is stored on or something, giving you a new URL.

 

If you instead were to buy a domain, lets say "altech.com" or something, and point it to the cloud hosted file (https://1drv.ms/t/s!Ar65S5uonmfNmPhZqSrE3JEbAGju2Q). Then if the URL changes or in the unlikely scenario that Microsoft goes bankrupt or similar, you can easily just point the altech.com domain somewhere else and your users won't be affected.

 

I understand if you do not want to pay for hosting and that you may be unable to host from home (if you are however able to do that, apache on a linux server is actually rather simple to setup). But buying a domain is generally very cheap and it could really help you out in scenarios like this one, if the Onedrive URL were to change in the future for some reason, just point it to wherever it is now.

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to post
Share on other sites

 

6 minutes ago, lubblig said:

Unsure, the code should likely work. That is very simple for you to test. What I'm unsure of is if the URL will change if the file is updated with new content. I don't think it will but it's a possibility. Also, now you are dependent on that this URL doesn't change. Which could happen, Microsoft may change what servers the file is stored on or something, giving you a new URL.

 

If you instead were to buy a domain, lets say "altech.com" or something, and point it to the cloud hosted file (https://1drv.ms/t/s!Ar65S5uonmfNmPhZqSrE3JEbAGju2Q). Then if the URL changes or in the unlikely scenario that Microsoft goes bankrupt or similar, you can easily just point the altech.com domain somewhere else and your users won't be affected.

 

I understand if you do not want to pay for hosting and that you may be unable to host from home (if you are however able to do that, apache on a linux server is actually rather simple to setup). But buying a domain is generally very cheap and it could really help you out in scenarios like this one, if the Onedrive URL were to change in the future for some reason, just point it to wherever it is now.

I'll try to buy a domain name. Once I have one, can I PM you asking how to set that up?

 

Thanks :).

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill

iPhone 8 Plus (Mid 2019 to present)

Samaritan XTX (Early 2021 Upgrade - AMD Ryzen 9 3900XT (12C/24T)  (2021) , MSI X370 Gaming Pro Carbon, Corsair 32GB Vengeance LPX DDR4-2666 (2020) ,  Asus ROG Strix RX Vega 56 , Corsair RM850i PSU, Noctua NH-D15 CPU Cooler (2021), Samsung 860 EVO 500GB SSD, Seagate BarraCuda 6TB HDD (2020) , NZXT S340 Elite, Corsair ML 120 Pro, Corsair ML120 x2 (2021)

Link to post
Share on other sites

@AluminiumTech You could host it from home and port forward. It won't be difficult.

Anyway,you can get free .tk domains online. It's not the most ideal but hey, it works.

 

I'm wondering if maybe you could check for the latest version somehow with github. Let me think a little bit.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites
4 minutes ago, Nineshadow said:

@AluminiumTech You could host it from home and port forward. It won't be difficult.

Anyway,you can get free .tk domains online. It's not the most ideal but hey, it works.

 

I'm wondering if maybe you could check for the latest version somehow with github. Let me think a little bit.

Hosting at home I agree with, I'm doing it right now and there are plenty of tutorials on how to run Apache on a linux machine.

 

I've never used a .tk domain before but as I was reading a guide by Godaddy, they claim that .tk domains cannot be forwarded. (source: https://se.godaddy.com/help/manually-forwarding-or-masking-your-domain-name-422)

This will only be a problem if you plan on hosting the file with a cloud service. If you host at home it shouldn't be an issue (I think).

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to post
Share on other sites
4 hours ago, AluminiumTech said:

 

I'll try to buy a domain name. Once I have one, can I PM you asking how to set that up?

 

Thanks :).

Yeah I'd think that's best. Since I've never used a domain to redirect to another URL (only hosted my own server with domains), I'm not sure how it works or if it works. You should look into it and see if you can get a domain that redirects that works with the "web.DownloadString" code. As what I've used before has been more like hosting the textfile on my server and accessing it via "example.com/version.txt" and not have it redirect from a subdomain like version.example.com to onedrive.ms.com/version.txt.

 

The problem I can see here is that the DownloadString doesn't work as it wants the direct link and possibly not the redirect part. I'm unsure and I think you should look into it.

 

As for the how to actually redirect, I looked at this tutorial on Godaddy that should work:

https://se.godaddy.com/help/manually-forwarding-or-masking-your-domain-name-422

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to post
Share on other sites

@lubblig I believe this may be a good opportunity to learn about version control.

 

You may want to start with Git and GitHub. You may have heard of these, they are the most common version control software and web git code hosting service around respectively.

 

There are many tutorials on the internet and GitHub has a quite nice desktop application for Windows (https://desktop.github.com/), which will make things easier. It would be very easy for you to create a GitHub account and upload your code to an online repository. Your application could have a text file, say VERSION.txt, containing the version number and this would be then automatically given the URL:

 

https://raw.githubusercontent.com/username/application-name/master/VERSION.txt

 

This will always point to the latest version of the file, no matter how many times you update your application.

Your application could download the text file and compare it with its own to check whether there is a new version available.

 

With git you can have multiple branches, e.g. a common setup includes:

- master (default) for your development code,

- stable for the default update channel,

- beta for your alternative update channel.

 

Finally, you get free hosting for your project using GitHub Pages (https://pages.github.com/).

 

Version control, GIT in particular, is extremely handy and popular, and most programming jobs will ask for experience in it.

 

 

Link to post
Share on other sites
On 2016-09-01 at 1:31 AM, policebox said:

@lubblig I believe this may be a good opportunity to learn about version control.

 

You may want to start with Git and GitHub. You may have heard of these, they are the most common version control software and web git code hosting service around respectively.

 

There are many tutorials on the internet and GitHub has a quite nice desktop application for Windows (https://desktop.github.com/), which will make things easier. It would be very easy for you to create a GitHub account and upload your code to an online repository. Your application could have a text file, say VERSION.txt, containing the version number and this would be then automatically given the URL:

 

https://raw.githubusercontent.com/username/application-name/master/VERSION.txt

 

This will always point to the latest version of the file, no matter how many times you update your application.

Your application could download the text file and compare it with its own to check whether there is a new version available.

 

With git you can have multiple branches, e.g. a common setup includes:

- master (default) for your development code,

- stable for the default update channel,

- beta for your alternative update channel.

 

Finally, you get free hosting for your project using GitHub Pages (https://pages.github.com/).

 

Version control, GIT in particular, is extremely handy and popular, and most programming jobs will ask for experience in it.

 

 

Yeah, I've been meaning to learn Git and use Github but it seems so complicated. I might just have to start learning it. It was a couple of years ago since I looked at it so there may be better tools/tutorials than what I could find back then.

 

Good tip btw!

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×