C
C#8mo 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 );
}
}
}
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`
c#

CS0103 The name 'Boo1' does not exist in the current context`
18 Replies
Gamerpost
GamerpostOP8mo ago
im new to this
Jimmacle
Jimmacle8mo ago
the error should tell you which line is the problem
Gamerpost
GamerpostOP8mo ago
No description
Gamerpost
GamerpostOP8mo ago
i cant find out whats the problem
Jimmacle
Jimmacle8mo ago
you made a typo, that's not what you should be passing to MarshalAs
Gamerpost
GamerpostOP8mo ago
its what the video said
Jimmacle
Jimmacle8mo ago
well if the video works and your code doesn't then you made a mistake
Gamerpost
GamerpostOP8mo ago
yeah
Jimmacle
Jimmacle8mo ago
compare what you have to the video and see what's different
Gamerpost
GamerpostOP8mo ago
nothing really ive checked 2 times
Jimmacle
Jimmacle8mo ago
can you share a screenshot of the part of the video you're copying?
Gamerpost
GamerpostOP8mo ago
No description
Jimmacle
Jimmacle8mo ago
i see several differences already compare unmanagedType: boo1 vs UnmanagedType.Bool
Gamerpost
GamerpostOP8mo ago
huh
Jimmacle
Jimmacle8mo ago
do you see how those two pieces of text are different?
Gamerpost
GamerpostOP8mo ago
they arent
Jimmacle
Jimmacle8mo ago
hate to tell you but they are programming is very precise, things like casing and the difference between : and . or 1 and l matter
Gamerpost
GamerpostOP8mo ago
oh yeahi thanks jimmacle fixed it
Want results from more Discord servers?
Add your server