Link to home
Start Free TrialLog in
Avatar of Ryan
RyanFlag for United States of America

asked on

Force Update on Open

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

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of Ryan

ASKER

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.
And what if you do this in main form load event?
SOLUTION
Avatar of Ryan
Ryan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan

ASKER

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.
Avatar of 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".
Avatar of Ryan

ASKER

Moving routine to a module allowed calling Restart, and single instance solved a created side effect.