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);
            });

 

posted on 2020-04-02 09:36  空明流光  阅读(353)  评论(0编辑  收藏  举报

导航