示例#1
0
        public void ModuleDomainTest()
        {
            IClrRuntime runtime = Process.Current.ClrRuntimes.Single();

            IClrAppDomain appDomainExe = runtime.GetAppDomainByName("AppDomains.exe");
            IClrAppDomain nestedDomain = runtime.GetAppDomainByName("Second AppDomain");

            IClrModule mscorlib = runtime.GetModuleByFileName("mscorlib.dll");

            AssertModuleContainsDomains(mscorlib, runtime.SharedDomain, appDomainExe, nestedDomain);
            AssertModuleDoesntContainDomains(mscorlib, runtime.SystemDomain);

            IClrModule appDomainsExeModule = runtime.GetModuleByFileName("AppDomains.exe");

            AssertModuleContainsDomains(appDomainsExeModule, appDomainExe);
            AssertModuleDoesntContainDomains(appDomainsExeModule, runtime.SystemDomain, runtime.SharedDomain, nestedDomain);

            IClrModule nestedExeModule = runtime.GetModuleByFileName("NestedException.exe");

            AssertModuleContainsDomains(nestedExeModule, nestedDomain);
            AssertModuleDoesntContainDomains(nestedExeModule, runtime.SystemDomain, runtime.SharedDomain, appDomainExe);
        }
示例#2
0
        public void ModuleAppDomainEqualityTest()
        {
            IClrRuntime runtime = Process.Current.ClrRuntimes.Single();

            IClrAppDomain appDomainsExe      = runtime.GetAppDomainByName("AppDomains.exe");
            IClrAppDomain nestedExceptionExe = runtime.GetAppDomainByName("Second AppDomain");

            Dictionary <string, Module> appDomainsModules = GetAppDomainModuleDictionary(appDomainsExe);

            Assert.True(appDomainsModules.ContainsKey("appdomains.exe"));
            Assert.True(appDomainsModules.ContainsKey("mscorlib.dll"));

            Assert.False(appDomainsModules.ContainsKey("nestedexception.exe"));

            Dictionary <string, Module> nestedExceptionModules = GetAppDomainModuleDictionary(nestedExceptionExe);

            Assert.True(nestedExceptionModules.ContainsKey("nestedexception.exe"));
            Assert.True(nestedExceptionModules.ContainsKey("mscorlib.dll"));

            Assert.False(nestedExceptionModules.ContainsKey("appdomains.exe"));

            // Ensure that we use the same Module in each AppDomain.
            Assert.Equal(appDomainsModules["mscorlib.dll"], nestedExceptionModules["mscorlib.dll"]);
        }