|
| Execute code from same Assembly in new AppDomain? |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.framework.clr.
| Christian Benien |
Hi,
I was wondering if it is possible to execute code from my (currently running) Assembly in another AppDomain. In this new AppDomain I want to do some reflection on other, unrelated assemblies. Then I want to unload the AppDomain and unlock those assemblies.
I tried with the following code:
[Serializable] class RemoteClass { public void Action() { Console.WriteLine(AppDomain.CurrentDomain.FriendlyName); } }
class Class1 { [STAThread] static void Main(string[] args) { AppDomainSetup setupInfo = new AppDomainSetup(); setupInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; AppDomain newDomain = AppDomain.CreateDomain("temporaryAppDomain", AppDomain.CurrentDomain.Evidence, setupInfo);
RemoteClass remote = newDomain.CreateInstanceAndUnwrap( Assembly.GetExecutingAssembly().FullName, "AppDomainTest.RemotingClass") as RemoteClass;
remote.Action(); AppDomain.Unload(newDomain); } }
The Action() function executes on the main AppDomain. Is it possible to get this to work? Or will the Action() function always be executed on the main AppDomain?
Cheers, Christian
|
|
|
| |
|
| |
| | |
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|