加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 即使在IIS的web.config中使用标签后,也会出现重复的

发布时间:2020-12-15 23:18:14 所属栏目:asp.Net 来源:网络整理
导读:我有一个网站在另一个网站的子目录中运行.它们运行在单独的应用程序池中.这两个站点正在运行不同版本的Entity Framework.所以在web.config中的子目录我有: remove name="entityFramework"/section name="entityFramework" type="System.Data.Entity.Interna
我有一个网站在另一个网站的子目录中运行.它们运行在单独的应用程序池中.这两个站点正在运行不同版本的Entity Framework.所以在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.

我也把< location>标签在父web.config中,尽可能:

<location path="." inheritInChildApplications="false">

<位置>标签存在于父web.config的< entityFramework>部分.

我已经在IIS的applicationHost.config文件(System32和SysWOW64中的这两个文件)中放置了enableConfigurationOverride =“false”.

如何防止子目录中的网站看到父实体框架标签?

编辑

IIS版本:7.5.7600.16385

从父web.config:

<configSections>
  <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,Version=6.0.0.0,PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>

<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,PublicKeyToken=b77a5c561934e089" requirePermission="false" />    
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection,Microsoft.Practices.EnterpriseLibrary.Common,Version=5.0.505.0,PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework" />
  </entityFramework>

编辑2

关于使用< clear />:这会导致关于缺少节声明的一系列错误.如果我添加了?100行的段声明,我得到错误:已检测到ASP.NET设置不适用于集成管理管道模式.即使我使用< validation validateIntegratedModeConfiguration =“false”/>在< system.webServer&gt ;.

解决方法

你能确认你是否尝试清除而不是删除问题仍然持续吗?
<configSections>
    <clear/>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>

你可能会读更多here

希望这将有助于您

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读