Reputation: 161
I created C++ Dll
Initialize()
{
if(!_fs.isOpened())
{
throw ERROR_FILE_NOT_FOUND;
_logfile << "Error ! Opening BDS.xml" << "\t" <<_arrivalTime<<endl;
_logfile.close();
}
}
and calling this function in C#
private void button1_Click(object sender, EventArgs e)
{
try
{
Initialize();
}
catch (RuntimeWrappedException ex)
{
MessageBox.Show(ex.Message);
}
}
But I am getting this error SEHException was Unhandled External Component has thrown an exception I tried C# all exception method but i did not get the correct answer. Can some One please help me?Or tell me how to throw exception from C++ Dll and Catch same Exception in C# and wait for response of C#. Like Retry, Abort, Ignore error, if Retry pressed than it again starts opening the file in Dll. how should i do this . please help me out of this.
Upvotes: 0
Views: 358
Reputation: 16243
It is C++\CLI not C++ exception. In C++\CLI, do the following:
throw gcnew System::Exception("It is a C++\CLI exception");
rather than c++ native exception
Upvotes: 2