Communications between AppDomains  
Author Message
Jarodtweiss





PostPosted: .NET Base Class Library, Communications between AppDomains Top

Hello All,

I want to make an application that will list all the types (having a parameterless ctor) from a DLL in a TreeView
And then I want to be able to dynamically create instances of the selected type ( just see that as Reflection Testing :-) )

I have one more constraint, I want the instance creation to be done in a separate AppDomain.

So what I was thinking to do is
- Create a new AppDomain
- Load the assembly in this new AppDomain
- "Read" the types in this new domain and pass the list back to the default AppDomain
- Populate the TreeView
- When selecting a node, creating the instance via reflection in the new AppDomain

My scenario is almost working.
- I can create a new Domain with AppDomain.CreateDomain
- I can pass information to my new domain using DoCallBack method and a method from a serializable instance

But by any mean I have tried, I cannot pass information back to my default domain (even "simple information" like a string)
- I have tried to populate my instance object but the value are not persisted
- I have tried to do again a DoCallBack to the default Domain but of course, my Default Domain do not have information about my loaded assembly. Let's imagine I resolve the assembly myself, then my next domain creation will also load this assembly in my new domain, which is not the scenario I want to do.

Do you have any idea of how I can do that (if this is possible)

Thanks,
Pierre-Emmanuel Dautreppe




.NET Development33  
 
 
TOM MCKEOWN





PostPosted: .NET Base Class Library, Communications between AppDomains Top

This will solve your problem

http://softwaresense.blogspot.com/2007/11/directly-invoking-methods-in-seperate.html