Exceptions propagating from unmanaged code to managed code?
I have a chunk of unmanaged C++ code I am reusing on a C# project. The
unmanaged C++ code is wrapped inside a layer of managed C++ code, which
interacts with the C# code. Right now, the unmanaged C++ code uses
assert(false) to raise critical errors. Since assert() writes to stderr
and my project is a GUI program I don't think the assert printouts will
show up. I'm thinking of replacing the assert(false) with throw new
exception(...) and then catch and display the exceptions at the C# GUI
layer. My questions are:
1) Is replacing assert() with exception() a good idea? if not why?
2) If exceptions are thrown inside unmanaged C++ code, will they propagate
properly to the managed C++ and then to C# code (with the stack trace
intact and correct)?
Thanks,
No comments:
Post a Comment