I created a VB.NET Windows Forms Application in Visual Studio 2008. When I run my program from the command-line, I get no output (only the next prompt).
What am I d
The solution is:
Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean
Declare Function FreeConsole Lib "kernel32.dll" () As Boolean
[code.....]
when needed the console output you just call AttachConsole(-1) but remember to do a FreeConsole() at the end of your program.
the only problem with this solution is that you will read something like this:
C:>yourapp.exe
C:>Hello World!
That's because a forms application runs as a child of the command prompt so the prompt returns immediately after you type the app name..
In a console application the command prompt returns after the program exits.
I am still trying to find a way to have the same behaviour (sync run) as in a console application.