Mono Linq向XML投掷SIGSEGV

时间:2013-08-28 11:28:41

标签: c# mono linq-to-xml monodevelop

在这个问题上,我一直在撞墙,我希望有人能够对下面的代码可能出现的问题提出一些建议。

我在Linux上使用MonoDevelop 4.0.9中的Mono 3.0.7开发了一个项目,该项目的目标是.NET 3.5。

我需要处理XML文件,因此我想使用Linq to XML来更轻松地使用XML文件。我在生成XML并将其写入文件时没有任何问题。但是,当我尝试从文件中读取内容时,Mono会因SIGSEGV错误而崩溃。

例如,我想尝试这样的事情:

//Load the document
XDocument indexFile = XDocument.Load(indexFilePath);

foreach (XElement acctElement in indexFile.Descendants("Account"))
{
    AcctCls acct = new AcctCls(acctElement.Attribute("AcctID").Value);
    AcctsList.Add(acct);

    foreach (XElement regionElement in acctElement.Descendants("Region"))
    {
        RegionCls region = new RegionCls(regionElement.Attribute("Region").Value);
        acct.RegionsList.Add(region);
    }
}

我尝试使用.NET Framework运行它,它似乎运行正常。但是,当我使用Mono运行时,我收到以下错误消息:

    Stacktrace:
      at <unknown> <0xffffffff>
      ...My own libraries...
      at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

    Native stacktrace:

        /usr/bin/mono() [0x4ae331]
        /usr/bin/mono() [0x503b8b]
        /usr/bin/mono() [0x4226b2]
        /usr/lib/libpthread.so.0(+0xf830) [0x7f4f68629830]
        /usr/bin/mono() [0x4d00d9]
        /usr/bin/mono() [0x4d5049]
        /usr/bin/mono() [0x4d5741]
        /usr/bin/mono() [0x4d583f]
        /usr/bin/mono() [0x4d67b5]
        /usr/bin/mono() [0x4d75fc]
        /usr/bin/mono() [0x4caeea]
        /usr/bin/mono() [0x4cb03e]

    =================================================================
    Got a SIGSEGV while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.
    =================================================================

当我做一件简单的事情时,我甚至会得到同样的错误:

    IEnumerable acctsList = indexFile.Descendants("Account");

    foreach(XElement acctElmnt in acctsList)
    {
        string test = acctElmnt.Attribute("AcctID").Value;
    }

我已经尝试将XMLReader放在using语句中并将该XMLReader传递给XDocument.Load方法,但这也无济于事。我不知道这是否相关,但是当我调试代码并逐步完成时,这种情况正在发生。

我已经谷歌搜索了几个小时,绞尽脑汁尝试一切,但我无法弄清楚如何让这个工作。 Mono网站说,它支持所有Linq to XML和我正在阅读的各种论坛和网站上的其他人似乎都能正常工作,所以我想知道我缺少什么。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

在玩了这个问题一段时间之后,我终于发现问题与尝试调试LINQ to XML语句有关。具体来说,这似乎每次我尝试进入LINQ to XML语句时都会发生。如果我没有进入语句,并且在没有调试的情况下正常运行应用程序,LINQ to XML工作正常。我认为这个问题可能与我上面的评论中提到的无法加载符号有关。