Solved

Force Update on Open

Posted on 2013-01-03
8
307 Views
Last Modified: 2013-01-08
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

0
Comment
Question by:Ryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38741708
0
 
LVL 13

Author Comment

by:Ryan
ID: 38741726
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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38741744
And what if you do this in main form load event?
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 13

Assisted Solution

by:Ryan
Ryan earned 0 total points
ID: 38741782
Seems to be the same behavior if I call the sub from Startup Event, or from my initialForm's Load event.  It updates and opens the new app, but doesn't close the original.

Module modGlobals
	Public Sub UpdateAsNeeded()
		If ApplicationDeployment.IsNetworkDeployed() Then
			If ApplicationDeployment.CurrentDeployment.CheckForUpdate Then
				ApplicationDeployment.CurrentDeployment.Update()
				'How do I force restart?
				Application.Restart()
				Application.DoEvents()
				Application.Exit()
			End If

		End If
	End Sub
End Module

Open in new window

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38741828
Well that's weird because its description says

Shuts down the application and starts a new instance immediately.


Keep trying in different places (shown event as well) and it nothing else works then trying making the app a single instance app and see if that works.
0
 
LVL 13

Author Comment

by:Ryan
ID: 38741883
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.
0
 
LVL 13

Author Comment

by:Ryan
ID: 38741894
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".
0
 
LVL 13

Author Closing Comment

by:Ryan
ID: 38754110
Moving routine to a module allowed calling Restart, and single instance solved a created side effect.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Windows app updating JSON file error. 9 39
Set custom font WPF 2 22
VB.net/VSTO Excel Add-in 2 19
.NET - find out if application is running on Windows 2012 server 3 37
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question