Ask Your Question

FileStorage::READ runtime exception

asked 2014-01-19 06:38:17 -0500

pistorinoj gravatar image

updated 2014-01-20 19:24:51 -0500

I am using OpenCV 2.4.6 with VS2012 c++/cli in Windows 8 and trying to simply read a matrix from a file. At runtime, I am crashing when I try and open the file and I am getting an error saying "System.Runtime.InteropServices.SEHException" - "External component has thrown an exception".

I have two questions: 1) what is causing this error; and 2) why is try/catch not handling this error?

My code looks like:

private: System::Void buttonLoadStyle_Click(System::Object^  sender, System::EventArgs^  e) {
    FileStorage fs;
    catch(cv::Exception& e)
        const char * err_msg = e.what();
        System::Windows::Forms::MessageBox::Show("Load Style Exception","Rune Time Error!",MessageBoxButtons::OK,MessageBoxIcon::Error);

        // do something

I get the exception when the the line tries to open the file. Further, the exception is not caught by my try/catch blocks.

Edit: When I remove the ".xml" extension, I execute past the line but, of course, do not find the file. Seems like it might be something with parsing the filename.

Any help greatly appreciated. Thanks

edit retag flag offensive close merge delete


Still no progress on this. Anyone else having the same issue?

pistorinoj gravatar imagepistorinoj ( 2014-02-09 18:58:07 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-02-12 11:06:40 -0500

pistorinoj gravatar image

updated 2014-02-12 11:09:03 -0500

I finally figured this out. If you improperly code your XML file so that it has multiple nodes with the same name, as soon as you try and open that file (not even reading anything from it) you will immediately get an error.

The error is "duplicate key." Once I corrected this, everything worked correctly.

Also, my catch statement was not specific to OpenCV and thus was not finding this error. Once, I fixed the catch statement, I got the correct error report and that led me to figure out that the XML file was coded incorrectly.

edit flag offensive delete link more

Question Tools


Asked: 2014-01-19 06:38:17 -0500

Seen: 3,303 times

Last updated: Feb 12 '14