I'm using clickonce, but I don't like having to change the minimum version number to force the update. It's less about forcing the update, as just not popping up the message box to the user asking if they want to update.
I don't care about installation times on startup, its typically only 5seconds or less, and the users are used to slower responses than that on most application startups. As a programmer, if I publish an update, I want the users to be updated at a maximum of the next time it's executed, with minimal interference to them.
Here's what I've developed, but I can't figure out how to restart? Am I in the wrong event?
The following code is in Application.Events
Partial Friend Class MyApplication Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup If ApplicationDeployment.IsNetworkDeployed() Then If ApplicationDeployment.CurrentDeployment.CheckForUpdate Then ApplicationDeployment.CurrentDeployment.Update() 'How do I force restart? 'Application.Restart ---This isn't available? End If End If#If Not Debug Then ExManager.ExceptionManager.AddHandler()#End If End Sub End Class
I moved the routine out of the StartupEvent and into a module which allowed me to call Application.Restart, then called the module from the startup.
It's all working, except that Restart doesn't close the current application, so I end up with 2 running, 1 old and 1 new. Calling Application.Exit after Restart doesn't close the old one.
Turning on Single Instance did solve the problem. I'm ok with using that option, it doesn't matter either way on my case. Thanks.
Ryan
ASKER
Hmm, well I just wanted to mark my final code as a solution and give credit for the single instance suggestion. Didn't know it would cause a "close question".
Ryan
ASKER
Moving routine to a module allowed calling Restart, and single instance solved a created side effect.
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.restart.aspx
http://madprops.org/blog/updating-clickonce-application-programatically/