我偶然发现了一个有趣的问题。我设法将问题减少到以下代码:
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 模式下工作得很好。