Home All Groups Group Topic Archive Search About

over write running .exe

Author
3 Feb 2006 3:42 PM
BobAchgill
I am using FTP built in to my application to update the application and data
from a server...

What is the normal method folks use to over write the application while the
program is active?  What I am running into is that the FTP code will not over
write the .exe while the application is running. 

Do any other types of application extension files have the same issue with
not wanting to be updated while the application is running: .dll, etc.??

Author
6 Feb 2006 12:57 PM
C-Services Holland b.v.
BobAchgill wrote:
> I am using FTP built in to my application to update the application and data
> from a server...
>
> What is the normal method folks use to over write the application while the
> program is active?  What I am running into is that the FTP code will not over
> write the .exe while the application is running. 
>
> Do any other types of application extension files have the same issue with
> not wanting to be updated while the application is running: .dll, etc.??

Impossible, you can't overwrite files that are in use (be it
executables, dll or whatever). Maybe you could write a sort of
monitoring program that will detect a new upload (to a specified
directory), shut down the program, copy/move the new program and start
the new version.


--
Rinze van Huizen
C-Services Holland b.v
Author
6 Feb 2006 1:10 PM
Jay B. Harlow [MVP - Outlook]
Bob,
Actually this is very much possible & actually quite easy in .NET. As Rinze
suggests normally one cannot "overwrite files that are in use", however .NET
has the ability to create a shadow copy of executables, such that you can
replace the original executable with the new one. To create a shadow copy of
an executable you set the shadow copy option when creating a new AppDomain,
then load your executable in this second app domain. This implies that your
app has a loader "stub" that creates the app domain & executes your actual
program. Using a FileSystemWatcher you could have the AppDomain
automatically restarted when a new version of the app is saved (However I
would simply inform my user to exit & restart the app).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemIOFileSystemWatcherClassTopic.asp



In .NET 2.0 (VS 2005) using ClickOnce is one of the easiest ways to
implement this app loader/updater.

Alternatively (.NET 1.x VS 2003) you can look at the Updater Application
Block:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/updaterv2.asp

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"BobAchgill" <BobAchg***@discussions.microsoft.com> wrote in message
news:DA686017-2462-428B-815F-D6362AC44737@microsoft.com...
|I am using FTP built in to my application to update the application and
data
| from a server...
|
| What is the normal method folks use to over write the application while
the
| program is active?  What I am running into is that the FTP code will not
over
| write the .exe while the application is running.
|
| Do any other types of application extension files have the same issue with
| not wanting to be updated while the application is running: .dll, etc.??
Author
8 Feb 2006 2:29 PM
C-Services Holland b.v.
Jay B. Harlow [MVP - Outlook] wrote:
Show quoteHide quote
> Bob,
> Actually this is very much possible & actually quite easy in .NET. As Rinze
> suggests normally one cannot "overwrite files that are in use", however .NET
> has the ability to create a shadow copy of executables, such that you can
> replace the original executable with the new one. To create a shadow copy of
> an executable you set the shadow copy option when creating a new AppDomain,
> then load your executable in this second app domain. This implies that your
> app has a loader "stub" that creates the app domain & executes your actual
> program. Using a FileSystemWatcher you could have the AppDomain
> automatically restarted when a new version of the app is saved (However I
> would simply inform my user to exit & restart the app).
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemIOFileSystemWatcherClassTopic.asp
>
>
>
> In .NET 2.0 (VS 2005) using ClickOnce is one of the easiest ways to
> implement this app loader/updater.
>
> Alternatively (.NET 1.x VS 2003) you can look at the Updater Application
> Block:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/updaterv2.asp
>

Wow.. you learn something new every day :) I was quite unaware of this.


--
Rinze van Huizen
C-Services Holland b.v