Executing unload.exe causes .Net CF apps to terminate

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I need to uninstall applications from within my .Net CF application. I
originally tried directly from my .Net app with a P\Invoke with:

CreateProcess("\windows\unload.exe", "CM TestApp", IntPtr.Zero,
IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, aPi)

It uninstalls the program (TestApp) as expected, but it also
terminates my
..Net application! I use other calls to to CreateProcess that work
fine, it is
just the call to unload.exe that causes the .Net app to terminate.

If I have multiple .Net apps running when I try to spawn the
unload.exe, they
all terminate.

I wrote a very simple MFC app that makes a direct call to
CreateProcess to
spawn the unload.exe with no adverse affects to the MFC app. If I have
any
..Net applications running when the MFC app makes the call; again, all
the .Net
apps terminate.

That leads me to believe that the unload.exe executable stops the .Net
framework, or something similar. Does anyone have a solution or
work-around?

Thanks,
Paul
 
Paul,

From your description, it sounds like sending a WM_CLOSE message to the
app's form that you want to close would be the main workaround.
 
Thanks for the response Ginny.

Based upon your answer, I don't think I described my problem
accurately. Let me try again.

My .Net CF app needs the ability to uninstall a previously installed
application. Normally, the user does this from the
'Start->Settings->System->Remove Programs' application. I am trying to
achieve this functionality programmatically. I am trying to do this
with the native call 'CreateProcess' on the unload.exe application. It
works, but a negative side affect is that any .Net applications that
are running at the time are terminated. I don't want them to
terminate.

I see the same negative side affect when I manually uninstall an
application using the 'Start->Settings->System->Remove Programs'
application. Any ‘.Net applications' running, when I uninstall an
application, is terminated.

I am not uninstalling a .Net application, all the ones I have
uninstalled are native applications (unmanaged), so I wouldn't think
there would be the need to unload .Net.

Thanks,
Paul
 
Paul,

Whenever unload.exe is invoked on a WinCE system, it first attempts to
close all of the running applications by sending them a WM_CLOSE message.
This is to free up any files that might be held by those applications, to
allow them to be deleted. Managed applications that need to keep running
should respond to the Form.Closing event and cancel it by setting Cancel =
true in the CancelEventArgs.

Stan Adermann
Developer
Microsoft .NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: (e-mail address removed) (Paul)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: Executing unload.exe causes .Net CF apps to terminate
| Date: 22 Apr 2004 16:22:03 -0700
|
| Thanks for the response Ginny.
|
| Based upon your answer, I don't think I described my problem
| accurately. Let me try again.
|
| My .Net CF app needs the ability to uninstall a previously installed
| application. Normally, the user does this from the
| 'Start->Settings->System->Remove Programs' application. I am trying to
| achieve this functionality programmatically. I am trying to do this
| with the native call 'CreateProcess' on the unload.exe application. It
| works, but a negative side affect is that any .Net applications that
| are running at the time are terminated. I don't want them to
| terminate.
|
| I see the same negative side affect when I manually uninstall an
| application using the 'Start->Settings->System->Remove Programs'
| application. Any ‘.Net applications' running, when I uninstall an
| application, is terminated.
|
| I am not uninstalling a .Net application, all the ones I have
| uninstalled are native applications (unmanaged), so I wouldn't think
| there would be the need to unload .Net.
|
| Thanks,
| Paul
|
 
Back
Top