Reputation: 2100
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?
Upvotes: 2
Views: 908
Reputation: 273274
Check the definition of the assert()
macro in your C library. It usually has a 'pluggable' output mechanism. Worst case you have to rewrite assert()
yourself.
The underlying problem here would be that a Console program has 2 output streams: normal and error. The System.Diagnostics.Process
class has a StandardError
property that can be used to intercept message written to the stderror
stream.
Upvotes: 3
Reputation: 93
Note that the defining NDEBUG turns off the assert mechanism. That identifier is defined per default in release-builds (/D-option). Check if the asserts work in the debug build of your dll and if so, edit your release-project settings to remove the /D option or any NDEBUG-definitions.
Upvotes: 1