Let's say I have a message in my output window (Showing output from Debug)
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
My application doesn't throw an exception, just displays that message and carries on. The exception occurs when I make a call to a method in an imported DLL which is a C++ module (my application is C#). The method still appears to function correctly in spite of this message appearing.
My guess is that that module is handling the exception and then displaying that message, but I want to be sure that this is the case and it's nothing to do how I've imported it or marshalled the data (or that custom marshaller).
(My code:
[DllImport("theExternalModule.dll", EntryPoint = "ReadData", SetLastError = true)]
[return: MarshalAs(UnmanagedType.U4)]
private static extern UInt32 ReadData([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(JaggedArrayMarshaler))] Int16[][] data,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(JaggedArrayMarshaler))] Int16[][] dataOrig,
[MarshalAs(UnmanagedType.U2)] Int16 buffsize,
ref int smpNum);
and
resultCode = ReadData(_buffer, _origBuffer, bufferSize, ref sampleNumber);
(when I step through this line in the debugger, the message is displayed)
My question is, is there a way of getting the output window to tell me what module or method caused that message to be displayed?