【发布时间】:2016-09-09 17:10:25
【问题描述】:
我有一个站点在另一个站点的子目录中运行。它们在不同的应用程序池中运行。这两个站点运行不同版本的实体框架。所以在子目录的 web.config 中我有:
<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
但即使使用<remove> 标签,我仍然会收到此错误:
Section or group name 'entityFramework' is already defined. Updates to this may only occur at the configuration level where it is defined.
我还在父 web.config 中尽可能放置了 <location> 标签:
<location path="." inheritInChildApplications="false">
<location> 标记出现在父 web.config 的 <entityFramework> 部分周围。
我已将enableConfigurationOverride="false" 放置在 IIS 的 applicationHost.config 文件中(System32 和 SysWOW64 中的文件)。
如何防止子目录中的网站看到父entityFramework标签?
编辑
IIS 版本:7.5.7600.16385
来自父 web.config:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
l
<location path="." inheritInChildApplications="false">
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</location>
来自子 web.config:
<configSections>
<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
l
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
编辑 2
关于使用<clear/>:这会导致一系列关于缺少部分声明的错误。如果我添加回约 100 行的部分声明,我会收到错误:An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. 即使我在 <system.webServer> 中使用 <validation validateIntegratedModeConfiguration="false" />,错误仍然存在。
【问题讨论】:
-
IIS 版本是多少?你能准确地展示你所拥有的 - 配置部分下的部分定义和实际的 EF 部分。
-
@G.Stoynev 我已经用您要求的信息更新了问题。
-
删除重复部分会怎样?您是否尝试解决指定程序集版本的此问题?
dependentAssembly> -
您是否尝试将
添加到 和 ?