Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
AppDomain.Load() is only meant to be called on AppDomain.CurrentDomain. (It's meant for interop callers only. They need a non-static method, and Assembly.Load() is static.) If you call it on a different AppDomain, if the assembly successfully loads in the target appdomain, remoting will then try to load it in the calling appdomain, potentially causing a FileNotFoundException/SerializationException for you.
If you need to execute an exe, use AppDomain.ExecuteAssembly() or (starting in v2.0) AppDomain.ExecuteAssemblyByName() instead. Otherwise, you should change to use Assembly.Load() from within the target appdomain. See Executing Code in Another AppDomain for more info.
Anonymous
June 18, 2003
The comment has been removed
Anonymous
June 20, 2003
You could still use remoting for process-to-process communication. (Actually, when you transfer objects from one AppDomain to another in the same process, it automatically uses remoting.)
Anonymous
September 13, 2007
The comment has been removed
Anonymous
May 06, 2010
AppDomain.load IS AN INSTANCE METHOD !!!!
"They need a non-static method, and Assembly.Load() is static."
The first part is right, it is non-static then you contradict yourself by saying that the method in question is static.
Anonymous
May 06, 2010
Ibrar:
I think there is a misunderstanding here. There is a Load() method in the Assembly class as well as the AppDomain class. The Assembly one is static; the AppDomain one is not. The point of the quoted sentence was to point out why AppDomain.Load() exists considering there is Assembly.Load().
Anonymous
June 03, 2010
Just as an FYI for those who may miss minute details (like myself): that MarshalByRefObject subclassing is crucial. I had been trying this without it, but I had loaded an assembly containing the launcher class in both appDomains. However, loading the assembly still resulted in both domains loading the assembly (and an error in the parent domain). Once the call is being done via marshaling, the problem went away, and everything worked exactly as expected.
Anonymous
June 17, 2010
Is it possible to load an assembly in separate AppDomain and return the reference on an assembly object to the main AppDomain?
Please sign in to use this experience.
Sign in