Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S <sunny.s@xxxxxxxxxxxxxxxx>
- Date: Sat, 12 Apr 2008 07:01:01 -0700
Hi Jeff,
Thanks for replying and for your comments. To answer your questions,
1. Yes, the app we are writing is being coded in Winform, it's not a Web
application, at least for the time being.
2. I can see two explanations for our design being strange to you:) - a) we
are doing something genuinely stupid; b) we are doing something genuinely new
(a combination of both is also an option:):):)). On a serious note, we are
trying to create an app that would host some other applications, either GUI
or non-GUI, which would be configurable through the host UI. The host is
supposed to be non-intrusive; once the apps are configured they should run as
there is no host, although they would be required to respond to host’s
request about their status.
3. Why don’t I call AppDomain.Unload()? I actually do, but there are
scenarios when I don’t want or cannot do this. (a) If the 3rd party app that
sits in this AppDomain is running a foreground thread then AppDomain.Unload
throws an exception. (b) If there is a problem with a 3rd party app, so that
it cannot continue, we would like to stop it - not in a graceful way, perhaps
- and grab some status data. Then we can unload the whole thing. (c) We
should be able to stop the 3rd party app, reconfigure it and start again.
4. Just to illustrate what I was talking about when I said that there were
limits to which Reflector could ‘reflect’, let’s take the Object class. Look,
for example, at
internal static extern bool InternalEquals(object objA, object objB)
As far as I know, there is no matching Win32 API to p/invoke and this is as
far as I can go in exploring the CLR internals.
Anyway, thank you very much for your help.
SS
"Jeffrey Tan[MSFT]" wrote:
Hi Sunny,.
Sorry for the late response to you, I am out of office yesterday. Anyway, I
am glad Willy has provided a great and informative discussion with you.
I assume your application is coded in Winform since you are using
System.Winforms.Forms.Application. So, your application created a seperate
AppDomain to host the 3rd party code for security/robustness reason ? Can
you tell us if the 3rd party code is also GUI code? This design and
achitecture looks strange to me, since I did not see any programs using this
design. We normally run the semi-trusted non-GUI addin in the separate
AppDomain.
I ask these because Application.Exit can only be used in GUI Winform code
not normal non-GUI code. Also, it can only shut down the GUI threads in the
*Application*. If the 3rd party code created a few more worker(non-GUI)
threads, they will be cleaned by Application.Exit. As Willy originally
pointed out, Application.Exit() has nothing to do with AppDomain, so it will
not help to clearn AppDomain. Why don't you call AppDomain.Unload method to
get rid of the buggy 3rd party code?
Regarding your last question, I think Reflector should be the best tool to
understand the .Net BCL internal work. What internal call functions do you
have problem to understand? As I know Winform purely encapsulates the Win32
GUI code, so I assume most of the non-.Net code is p/invoking the Win32
User32 APIs. The Win32 GUI programming books(such as <Programming Windows>)
should be good resource to help you understand GUI APIs.
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- Re: Relationship between Application.Exit() and AppDomain
- From: "Jeffrey Tan[MSFT]"
- Re: Relationship between Application.Exit() and AppDomain
- References:
- Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Scott M.
- Re: Relationship between Application.Exit() and AppDomain
- From: Jon Skeet [C# MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Jeffrey Tan[MSFT]
- Relationship between Application.Exit() and AppDomain
- Prev by Date: RE: Further to the Discussion
- Next by Date: Re: Relationship between Application.Exit() and AppDomain
- Previous by thread: Re: Relationship between Application.Exit() and AppDomain
- Next by thread: Re: Relationship between Application.Exit() and AppDomain
- Index(es):
Relevant Pages
|