locked
Sending strings to Output window from DLL

    Question

  • My C# app includes some C++ routines in a DLL. I can't set breakpoints in the C++ code, so I decided to send strings to the VS Output window as a means of debugging. But I can't seem to do that either. I tried the following syntax:

    std::cout << "Hello World";

    It compiles fine and executes ok, but the string doesn't show up in the Output window. Does anyone know what I might be doing wrong?

    Wednesday, August 29, 2012 7:22 PM

Answers

  • Use OutputDebugString to display debug output. There is no console and stdout is not connected to the Output window.

    You should be able to set breakpoints in the C++ code if you turn on mixed mode debugging.

    --Rob

    • Marked as answer by Bob Flora Wednesday, August 29, 2012 8:42 PM
    Wednesday, August 29, 2012 7:52 PM
    Owner

All replies

  • Use OutputDebugString to display debug output. There is no console and stdout is not connected to the Output window.

    You should be able to set breakpoints in the C++ code if you turn on mixed mode debugging.

    --Rob

    • Marked as answer by Bob Flora Wednesday, August 29, 2012 8:42 PM
    Wednesday, August 29, 2012 7:52 PM
    Owner
  • Thanks, Rob! I had tried switching to "Mixed" earlier but the app immediately threw a System.Runtime.InteropSvervices.SEHException. I tried it again at your suggestion and this time it worked. I don't know what changed, but I'm happy.

    Thanks for the tip about OutputDebugString as well. I didn't realize that WinAPI function was available in WinRT too.

    Wednesday, August 29, 2012 8:42 PM
  • You're welcome. I'm glad to hear it's working for you now.

    Technically OutputDebugString isn't allowed and it won't pass certification, but you only use it when debugging, and you can't certify a debug build anyway.

    --Rob

    Wednesday, August 29, 2012 9:02 PM
    Owner