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

  • SEARCH
  • Home
  • 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 6254295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:09:23+00:00 2026-05-24T14:09:23+00:00

I have a property whose instance I want to be in other domain. public

  • 0

I have a property whose instance I want to be in other domain.

public ModuleLoader Loader
        {
            get
            {

                if(_loader == null)
                    _loader = (ModuleLoader)myDomain.CreateInstanceAndUnwrap(
                              this.GetType().Assembly.FullName,
                              "ModuleLoader",
                              false, 
                              System.Reflection.BindingFlags.CreateInstance,                                  
                              null, 
                              null, 
                              null, 
                              null);
                System.Diagnostics.Debug.WriteLine("Is proxy={0}",
                             RemotingServices.IsTransparentProxy(_loader)); 
                                 //writes false
                 _loader.Session = this;
                 return _loader;
            }
        }

This works fine. But I assume all the method calls on _loader instance will invoke in other domain (myDomain). But when I run following code, it still writes main app domain.

public void LoadModule(string moduleAssembly)
        {
            System.Diagnostics.Debug.WriteLine("Is proxy={0}", 
                     RemotingServices.IsTransparentProxy(this));
            System.Diagnostics.Debug.WriteLine(
                          AppDomain.CurrentDomain.FriendlyName);
            System.Diagnostics.Debug.WriteLine("-----------");
        }

Is it because of Unwrap()? Where I am doing wrong?

I understand AppDomain creates seperate memory. What I need is my main application runs, it loads modules in different AppDomain. Since main app also wants to watch some activity of modules and interfare with objects running in seperate domain, what is the best way to achieve it.

  • 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-24T14:09:24+00:00Added an answer on May 24, 2026 at 2:09 pm

    If you want to actually run the code in the other assembly, you need to make your ModuleLoader class inherit from MarshalByRefObject. If you do that, CreateInstanceAndUnwrap() will actually return a proxy and the call will be executed in the other appdomain.

    If you don’t do that, and instead mark the class as Serializable (as an exception message suggests), CreateInstanceAndUnwrap() will create the object in the other appdomain, serialize it, transfer the serialized form to the original appdomain, deserialize it there and call the method on the deserialized instance.

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

Sidebar

Related Questions

hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I have a property whose value contains a $ . I'd like to use
I have a CurrentUser class with a static property whose value was stored in
I have a TextBox whose value is passed to an int property in an
I have a property on a domain object that is declared in a many-to-one
I have a property of type uint on my entity. Something like: public class
Say i have a property in a class: Vector3 position{get; set;} So i create
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
I have two collections which have property Email in both collections. I need to
I have a Property Grid in C#, loading up a 'PropertyAdapter' object (a basic

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.