I have a C# application which calls a native DLL. The native DLL calls AllocConsole to create a new console then WriteConsole to write to it. This behavior works fine when the application is run without a debugger attached. But when it is run with Visual Studio's managed debugger attached, the new console window still pops up when AllocConsole is called but nothing is written to it when I call WriteConsole.
It would seem like the debugger is intercepting the console commands and sending them to VS, but the text doesn't appear in any VS window that I can see (Output or Intermediate.) I can write to the VS windows intentionally by calling OutputDebugString, but I would really like to be able to write to the console made with AllocConsole, since I use functions like SetConsoleCursorPosition to let me overwrite the current console line. At the moment my work-around is something like
if(debuggerAttached) OutputDebugString(...) else WriteConsole(...)
Which is fairly inelegant and doesn't give me the functionality I want. Any ideas on how to get the VS debugger to not intercept the C++ console events? This problem doesn't occur when I'm in a purely native environment.