Got working with AppDomain.DoCallback which executes the code in the new AppDomain and doesnt load the assembly in the main AppDomain
Code:
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
AppDomain ad = AppDomain.CreateDomain("test", null, setup);
ad.DoCallBack(LoaderCallback);
AppDomain.Unload(ad);
private static void LoaderCallback()
{
Assembly ass = Assembly.Load("DllTest");
object o = ass.CreateInstance("DllTest.Testing");
Type t = o.GetType();
PropertyInfo pi = t.GetProperty("Test");
if (pi != null)
Console.WriteLine((string)pi.GetValue(o, null));
}