Avatar of Ryan
Ryan
Flag 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

Visual Basic.NET.NET ProgrammingC#

Avatar of undefined
Last Comment
Ryan

8/22/2022 - Mon
Nasir Razzaq

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.
Nasir Razzaq

And what if you do this in main form load event?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SOLUTION
Ryan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Nasir Razzaq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
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.
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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.