0

I attempted to use this post to help me https://stackoverflow.com/questions/4362111/how-do-i-show-a-console-output-window-in-a-forms-application use a console on a WinForms application but the output will not show, I have read over the "Duplicate questions" page and they all don't answer my question

I've tried using Debug. WriteLine but it doesn't work either. I'm assuming I'm missing a setting of some sort but they all say "use Managed Compatibility Mode" but its been gone for years, I'm having it open the console on a button press, and it opens the console it just won't output anything I've also tried "FreeConsole()" but it doesn't even open.

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();

private void button1_Click(object sender, EventArgs e)
        {
            AllocConsole();
            string message1 = "test123";
            Console.WriteLine(message1);
        }
Cience
  • 15
  • 4
  • Allocate the Console right after the Form is constructed (or in `Main`). Then, test your executable, not Visual Studio – Jimi Jul 26 '23 at 00:16

1 Answers1

0

If your Framework is outdated try updating it to 6.0 or above using this

https://devblogs.microsoft.com/dotnet/upgrade-assistant-now-in-visual-studio/

Again
  • 66
  • 6