0

我在尝试呈现 elmah 错误日志和使用 SQL DB 时收到错误消息。" http://localhost:5525/elmah" [ArgumentNullException: 值不能为空。参数名称:id] Elmah.ErrorLogEntry..ctor(ErrorLog log, String id, Error error) in c:\builds\ELMAH-1.2-SP2\src\Elmah\ErrorLogEntry.cs: 57 Elmah.SqlErrorLog.ErrorsXmlToList(XmlReader reader, IList errorEntryList) 在 c:\builds\ELMAH-1.2-SP2\src\Elmah\SqlErrorLog.cs:365 Elmah.SqlErrorLog.ErrorsXmlToList(String xml, IList errorEntryList) 在 c:\ c:\builds\ELMAH-1.2-SP2\src\Elmah\SqlErrorLog 中的 builds\ELMAH-1.2-SP2\src\Elmah\SqlErrorLog.cs:332 Elmah.SqlErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList)。 c:\builds\ELMAH-1.2-SP2\src\Elmah\ErrorLogPage.cs:186 Elmah.ErrorLogPage.OnLoad(EventArgs e):76 System.Web.UI.Control.LoadRecursive() +54 System.Web。 UI.Page.ProcessRequestMain(布尔包括StagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint) +772

我有最新的 Core Elmah 1.2-SP2 和最新的 Elmah.MVC 2.1.2。我使用默认的 web.config 设置安装了 Nuget 包 Elmah.MVC。

当我将 web.config 配置为将错误记录到数据库时,错误会记录在数据库中,但我无法呈现错误页面。当我不配置数据库时,elmah 页面呈现得很好。

  <elmah>
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Company" />
  </elmah>

反编译 Elmah 我在引发参数的构造函数中看到。

if (id == null)
        throw new ArgumentNullException("id");
      if (id.Length == 0)
        throw new ArgumentException((string) null, "id");

我在数据库中的所有 ErrorId 都是填充的 GUID。

我对没有将什么 id 传递给核心 elmah 感到困惑。有没有人遇到过这个?

4

1 回答 1

0

我下载了核心 Elmah 代码并逐步在 SqlErrorLog.cs 中找到方法 ErrorsXmlToList(XmlReader reader, IList errorEntryList) 调用获取 id 这是缺少的参数: string id = reader.GetAttribute("errorId"); 我将“errorid”小写,一切正常。显然这不是一个好的解决方案,因为这是每个人都使用的核心代码,所以我深入挖掘。

这使我查看了存储过程 ELMAH_GetErrorsXml。我在我们的数据库中发现我们有一个小写的“errorid”。我更新了存储过程以选择“errorId”并将核心 Elmah 更改回原始代码,当然一切正常。

于 2015-06-23T23:12:25.593 回答