Tuesday, February 26, 2008

Visual Studio/C++: Requested the Runtime to terminate?

The Visual Studio/Visual C++ woes continue. This time, my C++ application gave the message “This application has requested the Runtime to terminate it in an unusual way.” and my application died. This didn't happen on my development machine, but on a different machine on which I ran a Release build.

Googling gave me scary stuff, and that I'd need a hotfix that was not publicly available—you need to contact Microsoft to get it, so I did, and received the hotfix within the hour, but didn't need to install it anymore.

Turned out that the problem was something quite different. My application threw an exception, because a file was not found on the other machine. The error message actually meant to say: “This application threw an unhandled exception.” Thank you, Microsoft.

So, if you ever receive this message, before you look any further: make sure you catch every exception you throw.


Fabricio said...

you saved me!

Ashley Mills said...

Hey thanks. I was tearing my hair out.

I wasn't throwing any exceptions, but some included libraries were. Wrapping my entire program in this:

try {
} catch (std::exception& e) {
cout << e.what() << endl;

Revealed the culprit (in my case boost::filesystem couldn't remove a directory).

shiera said...

Thank you so much!!! Yes, I did install the Hotfix and it didn't help.

Thanks a lot also to Ashley Mills.

It was an exception thrown because of a folder boost::filesystem cannot find. And I didn't have try/catch in that part.