© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
25 replies
Gamerpost

✅ WinForms App

Trying to open console with a button click but i get a error (i tried following a tutorial)

My code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WinFormsApp2
{
    public partial class Form1 : Form

    {
        [DllImport("kerne132.dll", SetLastError = true)]
        [return: MarshalAs(unmanagedType: boo1)]
        static extern bool allocConsole();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            allocConsole();
            string message1 = "Hello, Starting..";

            Console.WriteLine(message1 );
        }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WinFormsApp2
{
    public partial class Form1 : Form

    {
        [DllImport("kerne132.dll", SetLastError = true)]
        [return: MarshalAs(unmanagedType: boo1)]
        static extern bool allocConsole();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            allocConsole();
            string message1 = "Hello, Starting..";

            Console.WriteLine(message1 );
        }
    }
}

Error:

CS0103    The name 'Boo1' does not exist in the current context`
CS0103    The name 'Boo1' does not exist in the current context`
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Winforms app
C#CC# / help
9mo ago
Package Winforms app into an installer
C#CC# / help
3y ago
Launch WinForms app when user inactive
C#CC# / help
4y ago
WinForms
C#CC# / help
2y ago