【问题标题】:Could not find schema information for the element 'elmah'找不到元素“elmah”的架构信息
【发布时间】:2012-12-04 13:04:06
【问题描述】:

我阅读了这里已经发布的所有答案,但似乎没有一个可以解决。 即使我收到这些警告,Elmah 的工作也完美无缺。当我在 Visual Studio 2012 中启动调试 (f5) 时,我也遇到了这些错误。在构建时一切都很好。

web.config 中的配置部分很简单,所以我真的不知道如何解决它:

<configuration>
  <configSections>
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
  </configSections>

  <elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="EvaConnection" />
    <!--<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/ErrorLogs" />-->
    <!-- ELMAH class ErrorMailModule.cs has been modified to read config from AppSettings -->
    <errorMail from="dummy@dummy.com" to="dummy@dummy.com" subject="dummy" priority="High" async="true" smtpPort="25" smtpServer="dummy" useSsl="false" userName="dummy@dummy.com" password="dummy" noYsod="false" />
  </elmah>

【问题讨论】:

  • 为了将来参考,GitHub 上有一个可用的 ELMAH 模式:github.com/elmahio/Elmah-Schema。您可以在此处阅读有关它的更多信息并查看有关如何使用它的示例:blog.elmah.io/the-elmah-schema
  • 要让 Intellisense 识别架构,至少在 Visual Studio 2015 中,架构根元素必须添加引用目标命名空间的默认命名空间属性:&lt;xs:schema xmlns:tns="http://Elmah.Configuration" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://Elmah.Configuration" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://Elmah.Configuration"&gt;

标签: asp.net web-config elmah configsection


【解决方案1】:

我认为这个错误与您选择 SqlErrorLog 作为您的 errorLog 类型有关。您是否在为您的EvaConnection connectionString 配置的数据库中运行了Elmah SQL Server DB Script?如果没有,您将需要这样做,以便为 Elamh 创建正确的表和存储过程,以便在将错误写入数据库时​​使用。

如果您使用的 SQL Server 版本高于 2005,请参阅ErrorLog Implementation - Enterprise-Level Relational Databases wiki 页面中的注释以获取有关 ntext 字段类型的注释。

更新:

多关注问题后。在 ELMAH Google Group - Could not find schema information 上找到相关帖子这是 Visual Studio 报告的有关 ELMAH 配置部分的问题,因为它没有支持的 .xsd 文件。有一个文件可用于在 Visual Studio 中抑制此错误/警告消息。只需按照Issue 239: Intellisense for web.config and external config files的说明进行操作

【讨论】:

  • 您好,库克,感谢您的回复。当然,SQL 表已设置好,一切正常。 Elmah 正在按预期记录和发送电子邮件。我认为这只是与 web.config 相关的东西,但我真的不知道如何解决它。我只在调试期间收到消息,在构建时一切正常。
  • 是否有某种 Visual Studio 缓存用于 Web 配置模式之类的东西? 的架构及其属性和元素应该从 正确读取(事实上,因为一切正常),但是在开始调试时我有“错误”消息(配置为信息消息,实际上没有错误)。所以我想也许是某种视觉工作室的缓存?
  • 谢谢库克。我想知道是否只有我收到这些消息。
  • @Manight 是的,可以从 XML 编辑器访问“缓存”。属性窗口中的Schemas 属性将打开 VS 知道的所有模式的网格。您可以在那里添加/删除和启用/禁用模式。如果您将 Elmah.xsd 放入您的项目并将 xmlns="http://Elmah.Configuration" 属性添加到您的 &lt;elmah&gt; 元素,VS 会自动将其架构添加到列表中。
  • 我这样做了,但警告仍然弹出,奇怪的是,如果我打开 Elmah.xsd 文件,它就会消失。
【解决方案2】:

我让一切正常,然后我也遇到了这个错误。

在您尝试任何更复杂的解决方案之前:

  1. 重新启动 Visual Studio
  2. 清理溶液
  3. 再次构建解决方案

这为我解决了问题。似乎某些东西在 Visual Studio 中被缓存(或崩溃)了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-20
    • 2013-11-29
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多