模組有無效的前置條件

Microsoft.Windows.InternetInformationServices.6.2.Module.has.an.invalid.precondition (Rule)

Knowledge Base article:

摘要

Internet Information Services (IIS) 8 可讓開發人員輕鬆設定原生與受管理的程式碼模組,這些模組負責處理網頁伺服器發出的要求。為讓工作者處理序能夠將它們載入,必須正確設定模組。在正確的模組組態中,模組必須具有唯一名稱,以及一個有效類型或路徑。受管理模組可指定是否只有對 ASP.NET 應用程式或對受管理處理常式的要求應呼叫這些模組。指定之後,此設定便可將效能最佳化。

解決方式

修正模組的前置條件

模組項目有選用的 preCondition 屬性,可包含所要載入模組的條件。例如,preCondition 可指定 IIS 僅針對在整合模式中執行的應用程式集區、在 ISAPI 模式中執行的應用程式集區或使用指定 NET Framwork 版本的應用程式集區載入模組。此最後一項設定可讓您針對使用不同版本的 CLR 執行階段的應用程式集區使用不同版本的受管理引擎模組。

以下範例取自具有 preCondition 屬性之模組項目的 ApplicationHost.config 檔案 globalModules 區段:

<globalModules>

     <add name="ManagedEngine"

           image="%Windir%\Microsoft.NET\Framework\v2.0.50727\webengine.dll"

           preCondition="integratedMode,runtimeVersionv2.0,bitness32"

      />

</globalModules>

在載入各個模組之前,伺服器會先評估組態中目前存在的前置條件。如果有任一載入前置條件傳回 false,便不會載入該模組。

若要解決此問題:

備份 ApplicationHost.config 檔案

備份 ApplicationHost.config 檔案:

系統將在 %Windir%\system32\inetsrv\backup 目錄底下使用您指定的備份名稱建立一個目錄。如果您不指定名稱,Appcmd.exe 會自動使用目前的日期和時間來產生目錄名稱。

在 ApplicationHost.config 檔案中尋找模組項目

在 ApplicationHost.config 檔案中尋找模組項目:

如需有關 globalModules 區段的詳細資訊,請參閱 IIS 8: 新增 globalModules 的元素 (IIS 設定結構描述) (英文)。

Element properties:

TargetMicrosoft.Windows.InternetInformationServices.6.2.WebServer
CategoryAlert
EnabledTrue
Event_ID2296
Event SourceMicrosoft-Windows-IIS-W3SVC-WP
Alert GenerateFalse
RemotableTrue
Event LogApplication

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.EventProvider Default
WA WriteAction Microsoft.Windows.Server.IIS.6.2.GenerateAlertAction.SuppressedByDescription Default

Source Code:

<Rule ID="Microsoft.Windows.InternetInformationServices.6.2.Module.has.an.invalid.precondition" Enabled="true" Target="Microsoft.Windows.InternetInformationServices.6.2.WebServer" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
<Category>Alert</Category>
<DataSources>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.EventProvider">
<ComputerName>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<LogName>Application</LogName>
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">PublisherName</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Microsoft-Windows-IIS-W3SVC-WP</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>2296</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="WA" TypeID="Microsoft.Windows.Server.IIS.6.2.GenerateAlertAction.SuppressedByDescription">
<Priority>1</Priority>
<Severity>1</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.Windows.InternetInformationServices.6.2.Module.has.an.invalid.precondition.AlertMessage"]$</AlertMessageId>
</WriteAction>
</WriteActions>
</Rule>