public ExecuteAssemblyByName ( AssemblyName assemblyName ) : int | ||
assemblyName | AssemblyName | |
리턴 | int |
private static System.AppDomain CreateAndRunAppDomain(int index, PermissionSet grantSet) { // Construct and initialize settings for a second AppDomain. AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = System.AppDomain.CurrentDomain.BaseDirectory; ads.DisallowBindingRedirects = false; ads.DisallowCodeDownload = true; ads.ConfigurationFile = System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; string name = "AppDomain" + index; System.AppDomain appDomain1 = System.AppDomain.CreateDomain( name, System.AppDomain.CurrentDomain.Evidence, ads, grantSet); var argsToPass = new string[] { name, index.ToString(), "SqlServer" }; appDomain1.ExecuteAssemblyByName( typeof(AppDomainInstanceProgram).Assembly.FullName, argsToPass); Console.WriteLine("**********************************************"); Console.WriteLine($"Finished executing in AppDomain {name}"); Console.WriteLine("**********************************************"); return(appDomain1); }
private static void CreateAndRunAppDomain(string appName) { // Construct and initialize settings for a second AppDomain. AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, appName); ads.DisallowBindingRedirects = false; ads.DisallowCodeDownload = true; ads.ConfigurationFile = Path.Combine(ads.ApplicationBase, appName + ".exe.config"); string name = appName; PermissionSet ps = new PermissionSet(PermissionState.Unrestricted); System.AppDomain appDomain1 = System.AppDomain.CreateDomain( name, System.AppDomain.CurrentDomain.Evidence, ads, ps); Console.WriteLine("**********************************************"); Console.WriteLine($"Starting code execution in AppDomain {name}"); appDomain1.ExecuteAssemblyByName( appName, new string[0]); Console.WriteLine($"Finished code execution in AppDomain {name}"); Console.WriteLine("**********************************************"); Console.WriteLine(); }