模块具有无效的前提条件

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

Knowledge Base article:

摘要

通过 Internet Information Services (IIS) 8,开发人员可轻松配置本机和托管的代码模块,这些模块用于处理向 Web 服务器发出的请求。为使工作进程可以加载模块,必须正确配置这些模块。正确的模块配置要求模块具有唯一名称和有效类型或路径。被管理的模块可以指定是否仅为对 ASP.NET 应用程序或被管理处理程序的请求调用它们。在指定对象之后,此设置可优化性能。

解决方法

更正模块的前提条件

模块入口具有可选的前提条件属性,此属性包含加载此模块的条件。例如,前提条件可指定 IIS 仅为运行在集成模式中、ISAPI 模式中或使用指定 .NET Framework 版本的应用程序池加载模块。此最后设置使使用不同版本的 CLR 运行时的应用程序池可以使用独立版本的被管理引擎模块。

下面的示例取自一个模块项的 ApplicationHost.config 文件的 globalModules 部分,其中该模块项具有 preCondition 属性:

<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>