SerializationException: Type is not resolved for member "..."
Asked Answered
S

1

16

I've been trying to dynamically load an assembly to an AppDomain. I need to do it because I want to call a method dynamically, but don't keep the handle to the DLL while my app is running, so that it can be replaced, if needed. But I'm getting this SerializationException exception: Type is not resolved for member "..."

Here's my code:

AppDomain domain = AppDomain.CreateDomain("Temp AppDomain", null, AppDomain.CurrentDomain.SetupInformation);
try {
    object obj = domain.CreateInstanceFromAndUnwrap(dllPath, typeName);
    IMyInterface myObj = (IMyInterface) obj;
    result = myObj.MyMethod(something);
} 
finally {
    AppDomain.Unload(domain);
}
Shadow answered 5/12, 2012 at 17:34 Comment(1)
Use Fuslogvw.exe to find out why it can't find the assembly with the type of that member.Duiker
S
35

Answer: The type had to extend MarshalByRefObject.

Shadow answered 11/12, 2012 at 15:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.