How to load an assembly into different AppDomain on Windows Mobile (.NET CF) for 开发者_如何学Pythonsubsequent AppDomain unload ?
AppDomain.Load is not available in CF.NET, but you can try executing an assembly. Keep in mind, that assembly needs to have a Main method.
AppDomain newDomain = AppDomain.CreateDomain("newDomain");
newDomain.ExecuteAssembly("Application.exe");
Try something like this:
class ServiceApplicationProxy : MarshalByRefObject
{
public void Configure()
{
Assembly serviceAssembly = Assembly.Load(new AssemblyName()
{
CodeBase = @"c:\fullpath\assembly.dll")
});
// do something
}
}
class Class1
{
public void Start()
{
Type activator = typeof(ServiceApplicationProxy);
AppDomain domain = AppDomain.CreateDomain(
"friendlyName", null, new AppDomainSetup());
ServiceApplicationProxy proxy =
domain.CreateInstanceAndUnwrap(
Assembly.GetAssembly(activator).FullName,
activator.ToString()) as ServiceApplicationProxy;
Console.WriteLine("Press ENTER to exit");
Console.ReadLine();
AppDomain.Unload(domain);
}
}
EDIT: From documentation at http://msdn.microsoft.com/en-us/library/system.appdomain(VS.71).aspx:
.NET Compact Framework Platform Note: The .NET Compact Framework does not support loading assemblies into a domain neutral code area for use by multiple application domains.
精彩评论