private void OnLoad() { Type loadertype = typeof(AppAssembly); AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationName = VirtualName; setup.ApplicationBase = FullPath; setup.CachePath = CachePath; setup.ShadowCopyFiles = "true"; setup.ShadowCopyDirectories = FullPath; setup.ConfigurationFile = FullPath + "app.config"; mAppDomain = AppDomain.CreateDomain( VirtualPath, null, setup); mDomainAssembly = (AppAssembly)mAppDomain.CreateInstanceAndUnwrap( loadertype.Assembly.GetName().Name, loadertype.FullName); mDomainAssembly.UnloadError = OnUnhandledException; mDomainAssembly.RunExe = RunExe; mDomainAssembly.VirtualName = VirtualName; mDomainAssembly.CallLogEvent = CallLogEvent; mDomainAssembly.SetArgs(Args); }