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