I have a property whose instance I want to be in other domain.
public ModuleLoader Loader
{
get
{
if(_loader
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.