2

我偶然发现了一个有趣的问题。我设法将问题减少到以下代码:

boost::property_tree::ptree properties;
boost::property_tree::read_xml("Additional Dependencies\\properties.xml", properties);

xml:

<Properties>

  <PictureGenerator>
    <miniatureHeight>4</miniatureHeight>
    <miniatureWidth>4</miniatureWidth>

    <imageHeight>8</imageHeight>
    <imageWidth>8</imageWidth>

    <ImagePath>Additional Dependencies\</ImagePath>
    <Miniatures>
      <Image>0.bmp</Image>
      <Image>1.bmp</Image>
      <!--<Image>2.bmp</Image>
      <Image>3.bmp</Image>
      <Image>4.bmp</Image>-->
    </Miniatures>

  </PictureGenerator>
</Properties>

当我在发布模式下构建项目时,一切都运行良好。在调试模式下,我收到以下错误:

Unhandled exception at 0x779e8e19 in my_project.exe: 0xC0000005: Access violation writing location 0x00000014.

我正在使用VS2010。经过进一步检查,当尝试从 basic_istream 创建向量时,会在 read_xml_internal 函数中引发错误。起初我以为我给出了错误的路径,但我在 Release 模式下工作得很好。

4

1 回答 1

1

我找到了问题的根源。我用 istream 重现了同样的错误,结果发现我为 Debug 设置了错误的属性页。

问题是财产:

C/C++ -> Code Generation -> Runtime Libary as Multi-threaded

我已将其更改为Multi-threaded Debug Dll并且效果很好。

于 2013-10-07T19:12:48.943 回答