Can't get Application.Restart to work

L

Lee

Hi,

I'm trying to programmatically restart my application after downloading
updates, but I can't get the Application.Restart command to work correctly.
It shuts down my program fine, but then doesn't start up again afterwards.

I read about Click Once in the MSDN but couldn't fathom if CO was supposed
to be a pre-requisite for getting it to work correctly.

Does anyone have any experience with this that could help me out? Or even an
alternative method of restarting a .Net v2.0 application?

Regards,

Lee.
 
S

Steve

Hi,

I'm trying to programmatically restart my application after downloading
updates, but I can't get the Application.Restart command to work correctly.
It shuts down my program fine, but then doesn't start up again afterwards..

I read about Click Once in the MSDN but couldn't fathom if CO was supposed
to be a pre-requisite for getting it to work correctly.

Does anyone have any experience with this that could help me out? Or evenan
alternative method of restarting a .Net v2.0 application?

Regards,

Lee.

From what I understand, double click on 'My Project' in 'Solution
Explorer'. Click on the option 'Publish' on the left side. Click the
'Updates' button. Check the box 'This application should check for
updates.' This will download new updates if they are available and
restart the program.
 
S

ShaneO

Lee said:
Hi,

I'm trying to programmatically restart my application after downloading
updates, but I can't get the Application.Restart command to work
correctly. It shuts down my program fine, but then doesn't start up
again afterwards.

I read about Click Once in the MSDN but couldn't fathom if CO was
supposed to be a pre-requisite for getting it to work correctly.

Does anyone have any experience with this that could help me out? Or
even an alternative method of restarting a .Net v2.0 application?

Regards,

Lee.
Lee, all the applications I've developed during the past couple of years
use my own upgrade/update routines, so I am experienced with what you're
asking. The solution I found a long time ago, and therefore still use
today, is to use the following lines of code after the update has
completed -

UpdateMessage("xxx is now Restarting...") 'My own StatusBar
messaging system.
Windows.Forms.Application.DoEvents()
Threading.Thread.Sleep(1000)
Application.Restart()
Application.Exit()
End 'Shouldn't be required! (But without it the app often "Crashes"
when it re-starts!!)

There's probably going to be people who will argue about the necessity
of one or more of the lines of code, and they can argue all they like,
because my own experience has shown that the above sequence works
EVERYTIME, whereas modifying or removing any single line causes problems.

I have approx 1,000 installed Users of various applications
incorporating the above code.

My applications are published to a Web Page. Install Mode is set to
being available offline (launchable from Start Menu), and Automatic
Updates are disabled.

Sometimes I find with .NET that certain things are just done, no real
reason or logic, they just have to be done that way!

I hope this helps.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 
L

Lee

Hi,

Thanks for the response.

I tried your code and it didn't restart the app, it just closed down as it
did previously. I'm guessing the reason why it's not restarting is becuase
of the publish option? I don't publish my application but instead upload the
files manually to my website for the program to detect.

Perhaps I should be looking to public instead of using a manual upload
method?
 
L

Lee

Hi,

Thanks for the response.

It does look like I may need to publich my application so i'm going to take
some time in looking at how that is done. Thanks for the pointers!


Hi,

I'm trying to programmatically restart my application after downloading
updates, but I can't get the Application.Restart command to work
correctly.
It shuts down my program fine, but then doesn't start up again afterwards.

I read about Click Once in the MSDN but couldn't fathom if CO was supposed
to be a pre-requisite for getting it to work correctly.

Does anyone have any experience with this that could help me out? Or even
an
alternative method of restarting a .Net v2.0 application?

Regards,

Lee.

From what I understand, double click on 'My Project' in 'Solution
Explorer'. Click on the option 'Publish' on the left side. Click the
'Updates' button. Check the box 'This application should check for
updates.' This will download new updates if they are available and
restart the program.
 
S

ShaneO

Lee said:
I tried your code and it didn't restart the app, it just closed down as
it did previously. I'm guessing the reason why it's not restarting is
becuase of the publish option? I don't publish my application but
instead upload the files manually to my website for the program to detect.

Perhaps I should be looking to public instead of using a manual upload
method?
Oh, I didn't realise you weren't "Publishing" the app. Yes, I'd agree
that everything will work fine once you start publishing, and besides,
it's simpler than having to update manually.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top