Prendiamo questo Snippet di codice:
using System;
using System.Runtime.Remoting;
using System.Reflection;
using System.Threading;
namespace AppDomTest
{
public class InvokeMethod
{
public static void Main( String[] argv )
{
AppDomainSetup info = new AppDomainSetup();
AppDomain dom = AppDomain.CreateDomain("RemoteDomain", null, info);
Foo f = dom.CreateInstance("AppDomTest", "AppDomTest.Foo").Unwrap() as Foo;
Foo f2 = new Foo();
Foo f3 = new Foo();
f3.PrintCounter();
AppDomain.Unload(dom);
Console.Read();
}
}
public class Foo : MarshalByRefObject
{
private static int _ci = 0;
public Foo()
{
_ci++;
}
public void PrintCounter()
{
Console.WriteLine("Counter is {0}", _ci);
}
}
}
Cosa viene a visualizzato?
- A. Counter is 1
- B. Counter is 2
- C. Counter is 3