is there any way to catch a C++ DLL exception in C#?
carey_amanda
0
Newbie Poster
Recommended Answers
Jump to PostYes. In your AssemblyInfo.cs add this:
[assembly:RuntimeCompatibilityAttribute(WrapNonExceptionThrows = true)]
Then to catch the exception:
private void button3_Click(object sender, EventArgs e) { try { //c++ call } catch (System.Runtime.CompilerServices.RuntimeWrappedException ex) { MessageBox.Show(ex.Message); } }
Jump to PostWhat is happening? Does the debugger give you any information, or are you seeing an error message dialog box open with the error details? Post a screenshot and output of when the operation fails.
Jump to PostI don't think you can do anything about that. From what you're saying the DLL is invoking the message box -- so an exception happens in the C++ DLL and they show a messagebox from the DLL. So really the exception is never making it to your application. You need …
All 10 Replies
sknake
1,622
Senior Poster
Featured Poster
carey_amanda
0
Newbie Poster
sknake
1,622
Senior Poster
Featured Poster
carey_amanda
0
Newbie Poster
carey_amanda
0
Newbie Poster
sknake
1,622
Senior Poster
Featured Poster
carey_amanda
0
Newbie Poster
sknake
1,622
Senior Poster
Featured Poster
sharn
0
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.