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 6159065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:04:08+00:00 2026-05-23T21:04:08+00:00

I thought I can get an reference to an object contained in the EXE

  • 0

I thought I can get an reference to an object contained in the EXE if I load the .net assembly(which is an exe) into my own appdomain and get the object reference through refleciton.

Can I really do this?

Here is my sample code…

myDomain = AppDomain.CreateDomain("MyAppDomain");
myDomain.ExecuteAssembly(exePath);

Assembly myAssembly = myDomain.GetAssemblies().Single(a => a.FullName.Contains("TestAssembly"));

Type t = commandsAssembly.GetType("TestClass");

By any way can I get a reference to an object of this type?

Edit:
In the main method of my EXE I am creating an object of type TestClass, I want a reference to that object. What I thought is ExecuteAssembly will execute the exe in the new appdomain, so when the EXE is instantiated my object would be created. Please correct me if I am wrong. CreateInstance will create a new object but I want reference to my object which gets created when EXE is executed… May be I am thinking in a stupid way, please correct me…

Thanks in Advance

  • 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-23T21:04:09+00:00Added an answer on May 23, 2026 at 9:04 pm

    Try commandsAssembly.CreateInstance ("TestClass"); or Activator.CreateInstance (t);

    EDIT – after the addition that all living instances are of interest:

    I think the only to achieve this is to write some sort of “debugger” which is really a tough call… some potentially usefull links

    http://blogs.msdn.com/b/davbr/archive/2011/02/01/clrprofiler-v4-released.aspx
    http://www.codeproject.com/Articles/122592/Writing-a-NET-debugger-part-1-Starting-the-debuggi
    http://www.codeproject.com/Articles/122591/Writing-a-NET-debugger-part-2-Handling-events-and
    http://www.codeproject.com/Articles/126142/Writing-a-net-debugger-part-3-symbol-and-source-fi
    http://www.codeproject.com/Articles/132798/Writing-a-NET-debugger-part-4-breakpoints
    http://msdn.microsoft.com/en-us/library/bb190764.aspx
    http://msdn.microsoft.com/en-us/library/ms229861.aspx

    The CLR profiler needs to do parts of you want – source is available so perhaps a good start…

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

Sidebar

Related Questions

How can I get the following test to pass with NHibernate? I thought it
I'm having trouble with something that I thought would be easy... I can't get
Can someone explain why I get different results from these two statements? I thought
I have a multi-module project. I thought I can compile only a single module
I thought I have seen this somewhere but can't find it any more on
I always thought an SQL compiler would break but apparently nesing can nearly be
I can't find anything definite using my favourite tool , however I thought I
How can we detect if a directed graph is cyclic? I thought using breadth
I thought I remembered reading somewhere a way to do this, but I can't
I thought there was something in GExperts to do this, but I can't see

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.