If you load the assembly into another appdomain, you should of course create instances there and use them there. Other than that, I'm not sure what the problem is that you are facing.
Update
- added code to select a type from the list
- changed only to package type names in domains as strings
using System; using System.IO; using System.Reflection; using System.Runtime.Remoting; public class MainClass : MarshalByRefObject { static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("usage: {0} assembly", Path.GetFileName(Assembly.GetExecutingAssembly().Location)); return; } AppDomain other = AppDomain.CreateDomain("other"); Type myType = typeof(MainClass);
Sample output for log4net.dll :
$ mono main.exe log4net.dll LoadAssembly executing in appdomain other Loaded assembly log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=a5715cc6d5c3540b. Types: [0] log4net.Core.SecurityContext [1] log4net.Core.LoggerWrapperImpl [2] log4net.Core.LogImpl [3] log4net.Core.DefaultRepositorySelector ... [160] log4net.Appender.AspNetTraceAppender [161] log4net.Appender.FileAppender ... [197] log4net.Repository.LoggerRepositoryConfigurationResetEventHandler [198] log4net.Repository.LoggerRepositoryConfigurationChangedEventHandler Enter index of type to create, -1 to exit: 161 Creating instance of type log4net.Appender.FileAppender CreateInstance executing in appdomain other Type of the created instance was: log4net.Appender.FileAppender
source share