“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常

2023-12-30

我正在 MVC 4 aspnet 网站中使用 EF5。 在本地,一切正常,但是当我将其发布到 IIS 并尝试进入时,出现错误

“‘System.Data.Entity.Internal.AppConfig’的类型初始值设定项 抛出异常。”

详细异常情况

创建配置节处理程序时发生错误 entityFramework:DbContext 类型的配置 'GdpSoftware.Server.Data.GdpSoftwareDbContext, GdpSoftware.Server.Data' 在中多次指定 应用程序配置。每个上下文只能配置一次。 (E:\App\web.config 第 104 行)

我在 StackOverflow 中检查了上一个问题,并且我已经通过 Nuget EntityFramework 卸载并重新安装,并检查每个项目中对其的每个引用都是 EF5。我还检查了每个项目中选择的框架是4.5。

任何想法,可能是什么导致了这个问题? 谢谢!吉列尔莫.

网络配置

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="GdpSoftwareConnectionString" connectionString="Persist Security Info=False;User ID=user;Password=password;Initial Catalog=databasename;Data Source=server" providerName="System.Data.SqlClient" />
    <add name="GdpSoftware.Server.Data.GdpSoftwareDbContext" connectionString="GdpSoftware.Server.Data.GdpSoftwareDbContext_ConnectionString" providerName="System.Data.SqlClient"/>
    <add name="GdpSoftware.Server.Ui.Web.Models.UsersContext" connectionString="GdpSoftware.Server.Ui.Web.Models.UsersContext_ConnectionString" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <!-- BEGIN - TO SEE THE ERRORS ON THE DEPLOYMENT-->
    <customErrors mode="Off" />
    <!-- END - TO SEE THE ERRORS ON THE DEPLOYMENT-->
  </system.web>
  <system.webServer>
    <!-- BEGIN - TO SEE THE ERRORS ON THE DEPLOYMENT-->
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true" />
    <!-- END - TO SEE THE ERRORS ON THE DEPLOYMENT-->
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <staticContent>
      <mimeMap fileExtension=".mustache" mimeType="text/plain" />
    </staticContent>
    <security>
      <requestFiltering>
        <fileExtensions>
          <add fileExtension=".mustache" allowed="true" />
        </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Castle.Windsor" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <contexts>
      <context type="GdpSoftware.Server.Data.GdpSoftwareDbContext, GdpSoftware.Server.Data" disableDatabaseInitialization="true">
        <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[GdpSoftware.Server.Data.GdpSoftwareDbContext, GdpSoftware.Server.Data], [GdpSoftware.Server.Data.Migrations.Configuration, GdpSoftware.Server.Data]], EntityFramework" />
      </context>
    </contexts>
  </entityFramework>
</configuration>

在 App.config 文件中执行以下操作:

  1. Put the connectionStrings元素位于configSections元素。
  2. Put the startup之后的元素connectionStrings元素。
<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <configSections>
         <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
   </configSections>
   <connectionStrings>
         <add name="SchedulingContext" connectionString="Data Source=XXX\SQL2008R2DEV;Initial Catalog=YYY;Persist Security Info=True;User ID=sa;Password=XXX"   providerName="System.Data.SqlClient"/>
   </connectionStrings>
   <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>       
 </configuration>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常 的相关文章

  • 如何在 MVC3 Razor 视图中呈现数据表

    我在 xls 电子表格 1 之间有一个可靠且经过测试的导入方法 该方法返回DataTable 我已将其定位在我的服务层中 而不是数据中 因为只有工作簿作为上传文件保存 但现在我想知道在哪里以及如何生成此内容的 HTML 表示形式DataTa
  • 使用 Kentor.AuthServices.StubIdp 作为生产 IDP

    我正在尝试在我的应用程序中实现 IDP SAML2 服务器 鉴于我的应用程序拥有所需的所有数据 我不希望我的任何合作伙伴要求我们的客户在他们这边注册 我对 SAML2 协议不是很熟悉 我找到了这个项目Kentor AuthServices
  • mvc4 捆绑包,它是如何工作的?

    在 mvc4 中 他们使用捆绑包来调用所有脚本和 css 文件一次 据我所知 调用js和cs文件时 它们的顺序很重要 如果我使用捆绑包 我如何知道捆绑包内的 css 和 js 文件的顺序是否正确 我可以定制订购吗 我现在的日期选择器有问题
  • Android 手机作为 GSM 调制解调器在 PC 上发送/接收短信?

    是否可以将 Android 移动设备用作 PC 上的 GSM 调制解调器 我正在 net下开发应用程序来发送 接收短信等 现在我想通过 USB 将我的 Android 设备连接到我的 PC 并将其用作 GSM 调制解调器来与其通信 这里是参
  • 为什么 appcmd.exe 解锁配置在 Azure 模拟器上不起作用?

    我最近升级到 Azure 2 1 SDK 现在我的部分功能遇到了问题web config在计算模拟器上运行时处于 Web 角色中 我的web config包含这个
  • ClickOnce 应用程序错误:部署和应用程序没有匹配的安全区域

    我在 IE 中使用 FireFox 和 Chrome 的 ClickOnce 应用程序时遇到问题 它工作正常 异常的详细信息是 PLATFORM VERSION INFO Windows 6 1 7600 0 Win32NT Common
  • 回发后刷新时提示确认表单重新提交。我做错了什么?

    我有一个以空白 默认状态启动的仪表板 我让用户能够将保存的状态加载到仪表板中 当他们单击 应用 按钮时 我运行以下代码 function CloseAndSave var radUpload find radUpload1ID var in
  • 动态添加 ASP.Net 控件

    我有一个存储过程 它根据数据库中存储的记录数返回多行 现在我想有一种方法来创建 div 带有包含该行值的控件的标记 如果从数据库返回 10 行 则 10 div 必须创建标签 我有下面的代码来从数据库中获取结果 但我不知道如何从这里继续 S
  • 如何用 Fluent 语法编写 HtmlHelper

    我有一个简单的标签生成器 如下所示 public static MvcHtmlString Tag this HtmlHelper helper string tag string content var tagBuilder new Ta
  • asp.net mvc强制在表单上获取url的样式

    我有一个用于搜索用户的简单表单 p Enter a user s id number to search p
  • 条件数据注释

    有没有办法使数据注释成为有条件的 我有一张桌子Party我存储组织和个人的地方 如果我要添加一个组织 我不需要该字段surname是必需的 但前提是我要添加一个人 public class Party Required ErrorMessa
  • ASP.NET Identity Extend 方法来访问用户属性

    我可以扩展方法来访问用户属性吗 有这样的方法 User Identity GetUserId User Identity GetUserName 可以从视图和控制器访问它们 我想使用以下方法扩展此功能 User Identity GetUs
  • 为什么当我使用 Server.Transfer() 时没有创建 HTTP 标头?

    我正在使用 aspx 页面根据给定的参数从文件系统提供图像文件 Server Transfer imageFilePath 当此代码运行时 会提供图像 但不会上一次更改HTTP 标头已创建 与直接从同一服务器上的 URL 调用同一文件不同
  • 如何在asp mvc的视图中加载选定的partialview?

    我正在从事 ASP NET Mvc 项目 我有一个类似于图像的视图 在此输入图像描述 https i stack imgur com xI6Fa jpg 我在布局中设计了右侧面板 我的布局代码 div class col md 3 pane
  • 如何在asp.net中创建动态复选框

    我正在创建一个需要添加动态复选框列表的应用程序 请任何人告诉我如何使用 C 添加动态复选框列表 在表单上放置一个带有 ID 的占位符placeHolder并将以下代码添加到您的Page Load CheckBoxList cbList ne
  • Automapper、Mapper 未初始化。使用正确的配置调用初始化

    当我尝试将数据提交到数据库时 出现以下错误 Success false Error true ErrorType 2 Message System InvalidOperationException Mapper 未初始化 使用适当的配置调
  • 如何反序列化 XML 文档

    如何反序列化此 XML 文档
  • MVC BaseController 处理 CRUD 操作

    我想重构我的基本 CRUD 操作 因为它们非常重复 但我不确定最好的方法 我的所有控制器都继承 BaseController 如下所示 public class BaseController
  • 我应该使用字节还是int?

    我记得曾在某处读到 即使您只需要字节 使用 Int32 更好 就性能而言 它 据说 仅适用于您不关心存储的情况 这是有效的吗 例如 我需要一个保存一周中某一天的变量 我是吗 int dayOfWeek or byte dayOfWeek E
  • Web 和 winforms 的 .Net 身份验证

    我有一个为客户端构建的 ASP NET Web 应用程序 它使用默认的 ASP NET 表单身份验证 他们现在请求一个能够 与 Web 应用程序一起工作的桌面 WinForms 应用程序 我已经创建了 Web 服务来访问他们想要从 Web

随机推荐