0

My winform application incorporates a 3rd-party dll (under the .NET 4.5) made by a device manufacturer in which I can use the exposed functions of its class to communicate with the device. But due to their crappy design once any function might fail no error detail can be retrieved from the class itself, but the class somehow put some information into the console window (appeared in the Output tab under Debug filter) in case of anything wrong.

Screenshot of VS2013

Now the problem is, the application can only be executed on the computer that is authorized to communicate otherwise the class won't initiate. So when I test my application on the trusted computer, I can only know that some functions return false but no debug info available. I've tried to add TraceListener to Trace.Listeners but nothing shows from this answer, I also tried Debug.Listeners with no result even I manually flushes after each while.

System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener("debug.txt"));
System.Diagnostics.Trace.AutoFlush = true;

The DebugView won't generate anything either, I don't know it's because I don't know how to properly use this tool or not. I just opened it, and nothing shows whatever I do to my application.

I'm highly suspicious that this DLL might just use some try...catch snippet to capture its own exceptions and output those info not by using Debug.Write(). What else I can do? I simply can't just install another Visual Studio on that trusted machine and debug my application there.

Ge Rong
  • 416
  • 5
  • 17

1 Answers1

1

Try adding a First-Chance Exception Handler:

using System;
using System.Runtime.ExceptionServices;

    class Example
    {
        static void Main()
        {
            AppDomain.CurrentDomain.FirstChanceException += 
                (object source, FirstChanceExceptionEventArgs e) =>
                {
                    Console.WriteLine("FirstChanceException event raised in {0}: {1}",
                        AppDomain.CurrentDomain.FriendlyName, e.Exception.Message);
                };

How to: Receive First-Chance Exception Notifications

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67