示例#1
0
 internal static void InitializeHostingFeatures(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException)
 {
   HttpRuntime._theRuntime.HostingInit(hostingFlags, policyLevel, appDomainCreationException);
 }
示例#2
0
 private void HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException)
 {
   using (new ApplicationImpersonationContext())
   {
     try
     {
       this._firstRequestStartTime = DateTime.UtcNow;
       this.SetUpDataDirectory();
       this.EnsureAccessToApplicationDirectory();
       this.StartMonitoringDirectoryRenamesAndBinDirectory();
       if (HttpRuntime.InitializationException == null)
         HostingEnvironment.InitializeObjectCacheHost();
       CacheSection cacheSection;
       TrustSection trustSection;
       SecurityPolicySection securityPolicySection;
       CompilationSection compilationSection;
       HostingEnvironmentSection hostingEnvironmentSection;
       Exception initException;
       this.GetInitConfigSections(out cacheSection, out trustSection, out securityPolicySection, out compilationSection, out hostingEnvironmentSection, out initException);
       HttpRuntime.CacheInternal.ReadCacheInternalConfig(cacheSection);
       this.SetUpCodegenDirectory(compilationSection);
       if (compilationSection != null)
       {
         HttpRuntime._enablePrefetchOptimization = compilationSection.EnablePrefetchOptimization;
         if (HttpRuntime._enablePrefetchOptimization)
           System.Web.UnsafeNativeMethods.StartPrefetchActivity((uint) System.Web.Util.StringUtil.GetStringHashCode(this._appDomainAppId));
       }
       if (appDomainCreationException != null)
         throw appDomainCreationException;
       if (trustSection == null || string.IsNullOrEmpty(trustSection.Level))
       {
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Config_section_not_present", new object[1]
         {
           (object) "trust"
         }));
       }
       else
       {
         if (trustSection.LegacyCasModel)
         {
           try
           {
             this._disableProcessRequestInApplicationTrust = false;
             this._isLegacyCas = true;
             this.SetTrustLevel(trustSection, securityPolicySection);
           }
           catch
           {
             if (initException != null)
               throw initException;
             throw;
           }
         }
         else if ((hostingFlags & HostingEnvironmentFlags.ClientBuildManager) != HostingEnvironmentFlags.Default)
         {
           this._trustLevel = "Full";
         }
         else
         {
           this._disableProcessRequestInApplicationTrust = true;
           this.SetTrustParameters(trustSection, securityPolicySection, policyLevel);
         }
         this.InitFusion(hostingEnvironmentSection);
         CachedPathData.InitializeUrlMetadataSlidingExpiration(hostingEnvironmentSection);
         HttpConfigurationSystem.CompleteInit();
         if (initException != null)
           throw initException;
         this.SetThreadPoolLimits();
         HttpRuntime.SetAutogenKeys();
         BuildManager.InitializeBuildManager();
         if (compilationSection != null && compilationSection.ProfileGuidedOptimizations == ProfileGuidedOptimizationsFlags.All)
         {
           ProfileOptimization.SetProfileRoot(this._codegenDir);
           ProfileOptimization.StartProfile("profileoptimization.prof");
         }
         this.InitApartmentThreading();
         this.InitDebuggingSupport();
         this._processRequestInApplicationTrust = trustSection.ProcessRequestInApplicationTrust;
         AppDomainResourcePerfCounters.Init();
         this.RelaxMapPathIfRequired();
       }
     }
     catch (Exception ex)
     {
       this._hostingInitFailed = true;
       HttpRuntime.InitializationException = ex;
       if ((hostingFlags & HostingEnvironmentFlags.ThrowHostingInitErrors) == HostingEnvironmentFlags.Default)
         return;
       throw;
     }
   }
 }