C#C
C#2y ago
Gamerpost

✅ WinForms App

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

My code:

c#

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:

c#

CS0103    The name 'Boo1' does not exist in the current context`
Was this page helpful?