当前位置: 首页>>代码示例>>C#>>正文


C# System.AppDomainSetup类代码示例

本文整理汇总了C#中System.AppDomainSetup的典型用法代码示例。如果您正苦于以下问题:C# AppDomainSetup类的具体用法?C# AppDomainSetup怎么用?C# AppDomainSetup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AppDomainSetup类属于System命名空间,在下文中一共展示了AppDomainSetup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildSetupInfo

        private AppDomainSetup BuildSetupInfo()
        {
            AppDomainSetup result = new AppDomainSetup();
            result.ApplicationBase = GetInstallPath();
            return result;

        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:AppDomainLoader.cs

示例2: ConvertsAfterAppDomainRecycles

        public void ConvertsAfterAppDomainRecycles()
        {
            // arrange
            Factory.TearDownAppDomain(null, null);

            var pathName = Path.GetDirectoryName(typeof(Factory).Assembly.Location);
            var appDomainSetup = new AppDomainSetup { ApplicationBase = pathName };
            var domain1 = AppDomain.CreateDomain("testing_unload_1", null, appDomainSetup);
            byte[] result1 = null;
            var domain2 = AppDomain.CreateDomain("testing_unload_2", null, appDomainSetup);
            byte[] result2 = null;

            // act
            domain1.DoCallBack(() =>
            {
                byte[] convert = Factory.Create().Convert("<p>some html</p>");
                AppDomain.CurrentDomain.SetData("result1", convert);
            });
            result1 = domain1.GetData("result1") as byte[];
            AppDomain.Unload(domain1);

            domain2.DoCallBack(() =>
            {
                byte[] convert = Factory.Create().Convert("<p>some html</p>");
                AppDomain.CurrentDomain.SetData("result2", convert);
            });
            result2 = domain2.GetData("result2") as byte[];
            AppDomain.Unload(domain2);

            // assert
            Assert.NotNull(result1);
            Assert.NotNull(result2);
        }
开发者ID:JamesPatison,项目名称:TuesPechkin,代码行数:33,代码来源:PechkinTests.cs

示例3: CreateAppDomain

        /// <summary>
        /// Creates an AppDomain.
        /// </summary>
        /// <param name="applicationName">The application name for the new AppDomain, or null if none.</param>
        /// <param name="applicationBaseDirectory">The application base directory for the new AppDomain, or null to use the current one.</param>
        /// <param name="configurationFile">The configuration file for the new AppDomain, or null to use the current one.</param>
        /// <param name="enableShadowCopy">If true, enables shadow copying within the AppDomain.</param>
        /// <returns>The new AppDomain.</returns>
        public static AppDomain CreateAppDomain(string applicationName, string applicationBaseDirectory, string configurationFile, bool enableShadowCopy)
        {
            AppDomainSetup appDomainSetup = new AppDomainSetup();

            appDomainSetup.ApplicationName = applicationName ?? string.Empty;
            appDomainSetup.ApplicationBase = applicationBaseDirectory ?? AppDomain.CurrentDomain.BaseDirectory;

            if (configurationFile != null)
            {
                // NOTE: We can also use AppDomainSetup.SetConfigurationBytes but it only applies to
                //       CLR-internal configuration settings such as the assembly binding policy.
                //       In order for other configuration mechanisms to operate correctly, we must
                //       use a real configuration file on disk instead.
                appDomainSetup.ConfigurationFile = configurationFile;
            }

            if (enableShadowCopy)
            {
                appDomainSetup.ShadowCopyFiles = @"true";
                appDomainSetup.ShadowCopyDirectories = null;
            }

            // TODO: Might need to be more careful about how the Evidence is derived.
            Evidence evidence = AppDomain.CurrentDomain.Evidence;
            if (DotNetRuntimeSupport.IsUsingMono)
            {
                return AppDomain.CreateDomain(appDomainSetup.ApplicationName, evidence, appDomainSetup);
            }
            else
            {
                PermissionSet defaultPermissionSet = new PermissionSet(PermissionState.Unrestricted);
                StrongName[] fullTrustAssemblies = new StrongName[0];
                return AppDomain.CreateDomain(appDomainSetup.ApplicationName, evidence, appDomainSetup, defaultPermissionSet, fullTrustAssemblies);
            }
        }
开发者ID:rprouse,项目名称:mbunit-v3,代码行数:43,代码来源:AppDomainUtils.cs

示例4: DefaultAppDomainManager_setup_for_web_domains_follows_same_approximate_pattern_as_web_applications

        public void DefaultAppDomainManager_setup_for_web_domains_follows_same_approximate_pattern_as_web_applications()
        {
            var module = new FakeCrosswalkModule
            {
                AppPoolInfo =
                    {
                        AppPoolName = "Testing",
                        ClrConfigFile = @"x:\no-such-folder\testing.config"
                    }
            };
            using (CrosswalkModule.ReplaceCalls(module))
            {
                var manager = new DefaultAppDomainManager();
                var setup = new AppDomainSetup();
                manager.InitializeNewDomain(setup);

                var domainId = module.AppPoolInfo.CreateAppDomain(@"x:\no-such-website\", "ID0", "CFG0");

                // the fake set of calls don't really create another domain
                Assert.That(domainId, Is.EqualTo(AppDomain.CurrentDomain.Id));

                // same default assumptions as a web app
                Assert.That(module.AppDomainSetup.ApplicationBase, Is.EqualTo(@"x:\no-such-website\"));
                Assert.That(module.AppDomainSetup.ConfigurationFile, Is.EqualTo(@"x:\no-such-website\Web.config"));
                Assert.That(module.AppDomainSetup.PrivateBinPath, Is.EqualTo(@"bin"));

                // specified a different class to finish initialization in the new domain
                Assert.That(module.AppDomainSetup.AppDomainManagerType, Is.StringEnding("WebAppDomainManager"));
            }
        }
开发者ID:loudej,项目名称:crosswalk,代码行数:30,代码来源:DomainManagerTests.cs

示例5: WithinAppDomain

 public static void WithinAppDomain(string expectedFile, string createdFile, IEnumerable<string> args)
 {
     var bd = AppDomain.CurrentDomain.BaseDirectory;
     var info = new AppDomainSetup()
     {
         ApplicationBase     = bd,
         ApplicationName     = Program + ".exe",
         ConfigurationFile   = Program + ".exe.config",
     };
     AppDomain ad = AppDomain.CreateDomain("DbMetal Sqlite Test", null, info);
     var t = typeof(DbMetalAppDomainSetup);
     var s = (DbMetalAppDomainSetup)ad.CreateInstanceAndUnwrap(t.Assembly.GetName().Name, t.FullName);
     var stderr = new StringWriter();
     s.SetStandardError(stderr);
     var testdir = Path.Combine(bd, Path.Combine("..", "tests"));
     var expectedDir = Path.Combine(testdir, "expected");
     s.Run(new []{
         "/provider:Sqlite",
         "/conn:Data Source=" + Path.Combine(testdir, "Northwind.db3"),
     }.Concat(args).ToArray());
     AppDomain.Unload(ad);
     if (stderr.GetStringBuilder().Length != 0)
         Console.Error.Write(stderr.GetStringBuilder().ToString());
     Assert.AreEqual(0, stderr.GetStringBuilder().Length);
     FileAssert.AreEqual(Path.Combine(expectedDir, string.Format (expectedFile, Program)), createdFile);
     File.Delete(createdFile);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:27,代码来源:AppRunner.cs

示例6: Main

        static void Main(string[] args)
        {
            object[] hostEvidence = { new Zone(SecurityZone.MyComputer) };
            Evidence internetEvidence = new Evidence(hostEvidence, null);
            AppDomain myDomain = AppDomain.CreateDomain("MyDomain");
            myDomain.ExecuteAssembly("SecondAssembly.exe", internetEvidence);

            AppDomainSetup setup = new AppDomainSetup();
            Console.WriteLine(setup.ToString());
            Console.WriteLine(typeof(object));

            objectArrayTest(new object[] { "Hello", "World"});

            AppDomainSetup ads = new AppDomainSetup();
            ads.ApplicationBase = "file://" + Environment.CurrentDirectory;
            ads.DisallowBindingRedirects = false;
            ads.DisallowCodeDownload = true;
            ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            AppDomain b = AppDomain.CreateDomain("New Domain", null, ads);

            ads = AppDomain.CurrentDomain.SetupInformation;
            Console.WriteLine("ApplicationBase: " + ads.ApplicationBase);
            Console.WriteLine("ApplicationName: " + ads.ApplicationName);
            Console.WriteLine("DisallowCodeDownload: " + ads.DisallowCodeDownload);
            Console.WriteLine("DisallowBindingRedirects: " + ads.DisallowBindingRedirects);
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:27,代码来源:Program.cs

示例7: Start

        /// <summary>
        /// Starts this instance.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Job already started.</exception>
        public static void Start()
        {
            if (_job != null)
                throw new InvalidOperationException("Job already started.");

            var evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            var setup = new AppDomainSetup
            {
                ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                ShadowCopyFiles = "false"
            };

            _appDomain = AppDomain.CreateDomain("eSync-" + Guid.NewGuid(), evidence, setup);
            try
            {
                var assembly = _appDomain.Load(typeof(SyncServiceJob).Assembly.GetName());
                var jobTypeName = typeof(SyncServiceJob).FullName;

                _job = (IJob)_appDomain.CreateInstanceAndUnwrap(assembly.FullName, jobTypeName);
                _job.Start();
            }
            catch
            {
                _job = null;
                AppDomain.Unload(_appDomain);
                _appDomain = null;

                throw;
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:34,代码来源:ESyncJob.cs

示例8: CreateGrainClientAssembly

        /// <summary>
        /// Generates one GrainReference class for each Grain Type in the inputLib file 
        /// and output one GrainClient.dll under outputLib directory
        /// </summary>
        private static bool CreateGrainClientAssembly(CodeGenOptions options)
        {
            AppDomain appDomain = null;
            try
            {
                var assembly = typeof (GrainClientGenerator).GetTypeInfo().Assembly;
                // Create AppDomain.
                var appDomainSetup = new AppDomainSetup
                {
                    ApplicationBase = Path.GetDirectoryName(assembly.Location),
                    DisallowBindingRedirects = false,
                    ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
                };
                appDomain = AppDomain.CreateDomain("Orleans-CodeGen Domain", null, appDomainSetup);

                // Set up assembly resolver
                var refResolver = new ReferenceResolver(options.ReferencedAssemblies);
                appDomain.AssemblyResolve += refResolver.ResolveAssembly;

                // Create an instance 
                var generator =
                    (GrainClientGenerator)
                    appDomain.CreateInstanceAndUnwrap(
                        assembly.FullName,
                        typeof(GrainClientGenerator).FullName);

                // Call a method 
                return generator.CreateGrainClient(options);
            }
            finally
            {
                if (appDomain != null) AppDomain.Unload(appDomain); // Unload the AppDomain
            }
        }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:38,代码来源:ClientGenerator.cs

示例9: IsolatedApplicationRunner

        public IsolatedApplicationRunner()
        {
            var setup = new AppDomainSetup
            {
                ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                ApplicationName = "Net IDE"
            };

            var appDomain = AppDomain.CreateDomain(
                setup.ApplicationName,
                AppDomain.CurrentDomain.Evidence,
                setup
            );

            try
            {
                _application = (ApplicationRunner)appDomain.CreateInstanceAndUnwrap(
                    typeof(ApplicationRunner).Assembly.FullName,
                    typeof(ApplicationRunner).FullName
                );

                _appDomain = appDomain;
            }
            catch
            {
                AppDomain.Unload(appDomain);

                throw;
            }
        }
开发者ID:netide,项目名称:netide,代码行数:30,代码来源:IsolatedApplicationRunner.cs

示例10: RunScriptInNewAppDomain

        /// <summary>
        /// Created a new <see cref="AppDomain"/> and runs the given PowerShell script.
        /// </summary>
        /// <param name="fileName">The name of the PowerShell script to run.</param>
        /// <param name="configFileName">The name of the configuration file. If you set it to null it will default to <code><paramref name="fileName"/>.config</code>.</param>
        /// <param name="appDomainName">The name of the AppDomain.</param>
        /// <returns>The output of the script as an array of strings.</returns>
        public static string[] RunScriptInNewAppDomain(ADPRConfig configuration)
        {
            var assembly = Assembly.GetExecutingAssembly();

            var setupInfo = new AppDomainSetup
                                {
                                    ApplicationName = configuration.AppDomainName,
                                    ConfigurationFile = configuration.ConfigFile,
                                    // TODO: Perhaps we should setup an even handler to reload the AppDomain similar to ASP.NET in IIS.
                                    ShadowCopyFiles = configuration.ShadowCopyFiles.ToString()
                                };
            var appDomain = AppDomain.CreateDomain(string.Format("AppDomainPoshRunner-{0}", configuration.AppDomainName), null, setupInfo);
            try
            {
            #if NET_35
                var runner = appDomain.CreateInstanceFromAndUnwrap(assembly.Location, typeof(AppDomainPoshRunner).FullName, false, 0, null, new object[] {configuration}, null, null, null);
            #else
                var runner = appDomain.CreateInstanceFromAndUnwrap(assembly.Location, typeof(AppDomainPoshRunner).FullName, false, 0, null, new object[] {configuration}, null, null);
            #endif
                return ((AppDomainPoshRunner)runner).RunScript(new Uri(Path.GetFullPath(configuration.Script)));
            }
            finally
            {
                AppDomain.Unload(appDomain);
            }
        }
开发者ID:zippy1981,项目名称:AppDomainPoshRunner,代码行数:33,代码来源:AppDomainPoshRunner.cs

示例11: OutputHubs

        private void OutputHubs(string path, string url, string outputPath)
        {
            path = path ?? Directory.GetCurrentDirectory();
            url = url ?? "/signalr";

            var assemblies = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories);
            var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Info(String.Format(CultureInfo.CurrentCulture, Resources.Notify_CreatingTempDirectory, tempPath));

            Directory.CreateDirectory(tempPath);

            // Copy all assemblies to temp
            foreach (var assemblyPath in assemblies)
            {
                Copy(assemblyPath, tempPath);
            }

            Copy(typeof(Program).Assembly.Location, tempPath);

            var setup = new AppDomainSetup
            {
                ApplicationBase = tempPath
            };

            var domain = AppDomain.CreateDomain("hubs", AppDomain.CurrentDomain.Evidence, setup);

            var generator = (JavaScriptGenerator)domain.CreateInstanceAndUnwrap(typeof(Program).Assembly.FullName,
                                                                                typeof(JavaScriptGenerator).FullName);
            var js = generator.GenerateProxy(path, url, Warning);

            Generate(outputPath, js);
        }
开发者ID:ZixiangBoy,项目名称:SignalR-1,代码行数:33,代码来源:GenerateHubProxyCommand.cs

示例12: GetVersion

        public static string GetVersion(string fileName)
        {
            var setup = new AppDomainSetup
            {
                ApplicationBase = Path.GetDirectoryName(typeof(VersionRetriever).Assembly.Location),
                ApplicationName = "Version Retriever"
            };

            var appDomain = AppDomain.CreateDomain(
                setup.ApplicationName,
                AppDomain.CurrentDomain.Evidence,
                setup
            );

            try
            {
                var retriever = (VersionRetriever)appDomain.CreateInstanceAndUnwrap(
                    typeof(VersionRetriever).Assembly.GetName().Name,
                    typeof(VersionRetriever).FullName
                );

                return retriever.GetVersionFromAssembly(fileName);
            }
            finally
            {
                AppDomain.Unload(appDomain);
            }
        }
开发者ID:netide,项目名称:netide,代码行数:28,代码来源:VersionRetriever.cs

示例13: RecyclableAppDomain

        public RecyclableAppDomain(string name, AppDomainSetup info)
        {
            domain = AppDomain.CreateDomain (name, null, info);

            //FIXME: do we want to allow resolving arbitrary MD assemblies?
            //domain.AssemblyResolve += new Mono.TextTemplating.CrossAppDomainAssemblyResolver ().Resolve;
        }
开发者ID:sewood,项目名称:ohNet,代码行数:7,代码来源:TextTemplatingService.cs

示例14: CreateAppDomain

 public static AppDomain CreateAppDomain(string name, string pluginPath)
 {
     AppDomainSetup setup = new AppDomainSetup();
     setup.PrivateBinPath = pluginPath;
     AppDomain domain = AppDomain.CreateDomain(name, null, setup);
     return domain;
 }
开发者ID:hach-que,项目名称:OgmoEditor,代码行数:7,代码来源:StaticAppDomainHelper.cs

示例15: GetRemoteTestObject

 private RemotingTest GetRemoteTestObject()
 {
     var ads = new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory };
     var ad = AppDomain.CreateDomain("test", null, ads);
     var test = (RemotingTest)ad.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "ReactiveTests.Tests.RemotingTest");
     return test;
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:7,代码来源:ObservableRemotingTest.cs


注:本文中的System.AppDomainSetup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。