I am using a legacy C Dll (I have the source code) that has numerous asserts scattered through the program. The dll is being used by a C# windows app.
The problem is that the “assertion failure” never shows up when there is an error in the DLL. The Dll is a console app (not sure if that’s relevant). There are dozens of asserts, and AFAIK there is no easy way to get the error mesg (or flag) back to the C# app without adding a lot of extra code.
Is there a way to force the output of the assert to the screen?
Check the definition of the
assert()macro in your C library. It usually has a ‘pluggable’ output mechanism. Worst case you have to rewriteassert()yourself.The underlying problem here would be that a Console program has 2 output streams: normal and error. The
System.Diagnostics.Processclass has aStandardErrorproperty that can be used to intercept message written to thestderrorstream.