C
C#7mo 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
GamerpostOP7mo ago
im new to this
Jimmacle
Jimmacle7mo ago
the error should tell you which line is the problem
Gamerpost
GamerpostOP7mo ago
No description
Gamerpost
GamerpostOP7mo ago
i cant find out whats the problem
Jimmacle
Jimmacle7mo ago
you made a typo, that's not what you should be passing to MarshalAs
Gamerpost
GamerpostOP7mo ago
its what the video said
Jimmacle
Jimmacle7mo ago
well if the video works and your code doesn't then you made a mistake
Gamerpost
GamerpostOP7mo ago
yeah
Jimmacle
Jimmacle7mo ago
compare what you have to the video and see what's different
Gamerpost
GamerpostOP7mo ago
nothing really ive checked 2 times
Jimmacle
Jimmacle7mo ago
can you share a screenshot of the part of the video you're copying?
Gamerpost
GamerpostOP7mo ago
No description
Jimmacle
Jimmacle7mo ago
i see several differences already compare unmanagedType: boo1 vs UnmanagedType.Bool
Gamerpost
GamerpostOP7mo ago
huh
Jimmacle
Jimmacle7mo ago
do you see how those two pieces of text are different?
Gamerpost
GamerpostOP7mo ago
they arent
Jimmacle
Jimmacle7mo 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
GamerpostOP7mo ago
oh yeahi thanks jimmacle fixed it
Want results from more Discord servers?
Add your server