c# winform 在新的应用程序域运行 wpf
var appName = "MobileExaming.exe"; var appPath = Application.StartupPath + @"\" + appName; var domain = AppDomain.CreateDomain("WpfAppDomain"); domain.ExecuteAssembly(appPath);
另一方法:
var domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; var adevidence = AppDomain.CurrentDomain.Evidence; var domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo); var type = typeof(Proxy); var value = (Proxy)domain.CreateInstanceAndUnwrap( type.Assembly.FullName, type.FullName); value.GetAssembly(Application.StartupPath + @"\MobileExaming.exe"); AppDomainHelper.Execute(domain, delegate() { var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(item => item.ManifestModule.ScopeName == "MobileExaming.exe"); AppDomain.CurrentDomain.ExecuteAssemblyByName(assembly.FullName); });
桂棹兮兰桨,击空明兮溯流光。