How to load an assembly into different AppDomain on Windows Mobile (.NET CF) for subsequent AppDomain unload ?
views:
302answers:
1
A:
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.
Rubens Farias
2010-01-15 02:23:37
Hi Rubens, I appreciate your efforts to answer my question.However CreateInstanceAndUnwrap method is not available on .NET Compact Framework.
kriau
2010-01-15 03:11:25
Sorry, when I saw `AppDomain` available on CF, I assumed all type methods would be also available
Rubens Farias
2010-01-15 10:13:15