Re: Relationship between Application.Exit() and AppDomain



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.



.



Relevant Pages

  • Re: Relationship between Application.Exit() and AppDomain
    ... AppDomain to host the 3rd party code for security/robustness reason? ... I ask these because Application.Exit can only be used in GUI Winform code ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Great SWT Program
    ... keyboard shortcuts aren't always obvious. ... A user using a GUI app may notice something ... and notice tedium using a GUI app to do it. ... specifically think of the feature they wanted and couldn't find in it. ...
    (comp.lang.java.programmer)
  • Re: MacUpdatePromo
    ... easy way to know which app will work which way. ... so users are supposed to know all GUI guidelines and understand the ... when they close a window. ... them to quit. ...
    (comp.sys.mac.advocacy)
  • Re: Starting exe from WebService
    ... Ok, when you said it was WinForm app that you were trying to execute, I ... > WebService because the program is complicated and I don't ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Can ooRexx, Regina and Reginald coexist?
    ... I pretty much agree with your point of view, but only as a programmer. ... Faced with an app with one GUI which I understood I'd hope I could set it up ... However I wouldn't expect a non-programmer to be able to take a reginald ...
    (comp.lang.rexx)