Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347402
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:25:03+00:00 2026-05-18T01:25:03+00:00

I want to launch a WPF App, in a 2nd AppDomain, from a ‘loader’

  • 0

I want to launch a WPF App, in a 2nd AppDomain, from a ‘loader’ class. If the WPF App times itself out, I want it to fire an event back to the loader class and the loader class will Unload() the the 2nd AppDomain and show a login screen. If the user logs back in, the same process will repeat.

I have this working to a degree by :

  1. Loader class creates the 2nd AppDomain and class B in that domain via CreateInstanceAndUnwrap.

  2. Loader class creates a MarshalByRefObject that has a Timeout event, and passes it to a B.StartUp(MBRO), which passes the MBRO on to the constructor of the WPF App(). Loader class adds a handler to MBRO.Timeout.

  3. WPF App times out, calls MBRO.Timeout, which is handled by the Loader class. In the event handler, Loader class shuts down B WPF App and shows the login window.

The problem is that I can’t Unload the 2nd AppDomain in step 3. When I do it, it shuts down the host appdomain as well (no exceptions or anything, the whole thing shuts down).

I think the problem happens because the event handler delegate is being fired by the WPF App which is in the 2nd domain, and therefore I am trying to pull the rug from under App Domain from within a delegate it has fired.

Is this correct? Does it work like this across Domains?

In summary, can anyone suggest a way where you can launch a 2nd AppDomain, receive an event from the 2nd AppDomain and Unload() the 2nd AppDomain upon receiving that event? I think I need someone to decouple the receipt of the event from the act of Unloading the app domain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:25:04+00:00Added an answer on May 18, 2026 at 1:25 am

    Yes, this is correct. The problem is that the stack trace passes from the primary domain through the second domain and back to the primary domain.

    You have a few choices here.

    1. You call into the app domain. If you could make it so that the method you call returns with a specific status code (e.g. Success or Timeout), you don’t have the stack problem anymore;

    2. You call the app domain from a second thread:

      1. From the first thread, create a new thread which creates the app domain and starts the application;

      2. Still in the first thread, create a AutoResetEvent and do a WaitOne() on that;

      3. When the event is executed from the app domain, it will not execute on the first thread. I’m not sure whether the event will execute on the second event and if not, creating the secondary thread will not be necessary. From the thread the comes in on, set a ‘Timeout’ flag somewhere and do a Set() on the event;

      4. The primary thread wakes up and knows what to do depending on the status of the flag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.