Hi.. Vadym,
The code is something like:
In AppDomain0, I define:
public interface IA { void M(); }
In AppDomain1, there is a interface defined:
public interface IA {void M(); } //exactly same as IA in AppDomain0
public class A : IA {... } //class A implements IA
I compiled A.dll which contains IA and A.
The following program does:
0. launch the main program running in AppDomain0. Main program has a IA
interface defined.
1. create a new AppDomain, AppDomain1
2. load the A.dll into AppDomain1
3. Create a remote object and try to convert it to IA.
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = this.path;
setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory;
setup.ApplicationName = "A.dll";
setup.ShadowCopyFiles = "true";
setup.ShadowCopyDirectories = AppDomain.CurrentDomain.BaseDirectory;
AppDomain appDomain = AppDomain.CreateDomain("A", null, setup);
IA a = (IA)appDomain.CreateInstanceFromAndUnwrap(fileName , "A"); //Error!
Compile is fine. When I run the program, it complains about not being able
to cast a transparent proxy to type IA.
thanks again.
"Vadym Stetsyak" wrote:
Hello, Tao!
Its hard to tell the answer without additional information. Can
you post a small code sample, where you define
interfaces and try to convert them?
You wrote on Wed, 8 Nov 2006 10:54:02 -0800:
Thi. guys,
TI have two AppDomains, AppDomain0 and AppDomain1. In AppDomain1, I
Tgot a
Tclass implements an interface IInterface0. In AppDomain0, I also
Tdefine a
TIInterface0, the code of two interfaces are exactly same.
TWhen I call:
TappDomain.CreateInstanceFromAndUnwrap and try to convert to
TAppDomain0.IInterface0. I got an error.
TI was wondering why? Their codes are exactly same. Is there any way
Tthat I
Tcan do such cast?
TI hope I explain this problem clearly.
Tthanks, guys
--
With best regards, Vadym Stetsyak.
Blog: http://vadmyst.blogspot.com