Iis-7

為什麼我的應用程序在 IIS7.5 中需要 32 位模式?

  • March 16, 2011

我有一個在 64 位 2008 伺服器上執行的 .net4 Web 應用程序。只有當我將應用程序池設置為啟用 32 位應用程序為 true 時,它才能執行。所有 dll 都是為 .net4 編譯的(使用 corflags.exe 驗證)。我怎樣才能弄清楚為什麼需要啟用 32 位?

作為 64 位應用程序池啟動時來自事件日誌的錯誤消息

事件程式碼:3008 事件消息:發生配置錯誤。事件時間:2011-03-16 08:55:46 事件時間(UTC):2011-03-16 07:55:46 事件 ID:3c209480ff1c4495bede2e26924be46a 事件順序:1 事件發生:1 事件詳細程式碼:0

應用程序資訊:應用程序域:已刪除信任級別:完整應用程序虛擬路徑:已刪除應用程序路徑:已刪除機器名稱:NMLABB-EXT01

程序資訊:程序 ID:4324 程序名稱:w3wp.exe 帳戶名稱:已刪除

異常資訊:異常類型:ConfigurationErrorsException 異常消息:無法載入文件或程序集“System.Data”或其依賴項之一。試圖載入格式不正確的程序。在 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) 在 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() 在 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() 在 System.Web.Compilation.BuildManager。 GetReferencedAssemblies(CompilationSection compConfig) 在 System.Web.Compilation.BuildManager.CallPreStartInitMethods() 在 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory,

無法載入文件或程序集“System.Data”或其依賴項之一。試圖載入格式不正確的程序。在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字元串程式碼庫,證據 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark 和 stackMark,布爾 throwOnFileNotFound,布爾 forIntrospection,布爾 suppressSecurityChecks)在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,證據 assemblySecurity,StackCrawlMark 和標記堆棧, Boolean for Introspection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 在 System.Reflection.Assembly.Load(String assemblyString) 在 System。

請求資訊: 請求 URL:“our url” 請求路徑:“url” 使用者主機地址:ip-address 使用者:

是否認證:False 認證類型:

執行緒賬戶名:“app-pool”

執行緒資訊:執行緒 ID:6 執行緒帳戶名稱:“app-pool”正在模擬:錯誤堆棧跟踪:在 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) 在 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory () 在 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() 在 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) 在 System.Web.Compilation.BuildManager.CallPreStartInitMethods() 在 System.Web.Hosting.HostingEnvironment.Initialize (ApplicationManager appManager、IApplicationHost appHost、IConfigMapPathFactory configMapPathFactory、HostingEnvironmentParameters hostingParameters、PolicyLevel policyLevel、異常appDomainCreationException)

自定義活動詳情:

很可能是因為您的應用程序使用的一個或多個組件是 32 位的。

或者,因為當您切換應用程序池模式時,由於它們的位數和文件系統重定向,找不到您的應用程序使用的一個或多個組件。

一般來說,IIS 會將 Modules 和 Handlers 劃分為 32 位和 64 位二進製文件,並以 bitness32 或 bitness64 前提條件防止一個或另一個位看到另一個位。

頭頂範例:

<modules> <module name="something" path="c:\program files\something.dll" precondition="bitness64"> </modules>

如果您將應用程序池更改為 32 位,請記住:

  • bitness64 不會是真的
  • 64 位應用程序不會對文件位置撒謊;32 位應用程序可能是(程序文件(x86)或 System32(重定向到 SysWow64))

同一個模組/處理程序可能有這樣的條目:

<modules> <module name="something32" path="c:\program files\something32.dll" precondition="bitness32"> </modules>

僅當something32.dll 在程序文件(x86)中時才有效。

如果是模組或處理程序載入失敗,事件日誌應該可以幫助您跟踪哪個模組有問題。

如果您的模組或處理程序未指定位數前提條件,並且由於重定向而從不同位數執行時可能使用不同的路徑,那麼您就有問題了。(事件日誌通常會指出當應用程序池無法啟動時載入失敗的內容)。

也可以看看:

引用自:https://serverfault.com/questions/247667