C
C#2y ago
Elmishh

✅ windows forms app on .NET framework

followed the guide from microsoft to make a button that says hello world when pressed and now i have 15 errors after typing 1 line of code and changing namespace [???] to something else and i have NO IDEA WHAT IM DOING WRONG
16 Replies
Elmishh
ElmishhOP2y ago
anyone?
Shinigami
Shinigami2y ago
Make sure to include the required assemblies System.Windows.Forms
reflectronic
reflectronic2y ago
and changing namespace [???] to something else
the problem is that you did this you can't
Elmishh
ElmishhOP2y ago
why cant i
reflectronic
reflectronic2y ago
well, yo ushould be able to make it work, let me try something
Elmishh
ElmishhOP2y ago
btw forgot to say but it changed
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;

namespace HelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void label1_Click(object sender, EventArgs e)
{
lblHelloWorld.Text = "Hello World!";
}
}
}
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;

namespace HelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void label1_Click(object sender, EventArgs e)
{
lblHelloWorld.Text = "Hello World!";
}
}
}
is the current code
Elmishh
ElmishhOP2y ago
and im getting
Elmishh
ElmishhOP2y ago
in
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
line 18 Application.Run(new Form1()); ^^^^^ that didnt work
reflectronic
reflectronic2y ago
well, you changed the namsespace so it can't find new Form1() anymore. you moved it
Elmishh
ElmishhOP2y ago
?
reflectronic
reflectronic2y ago
you need to change the namespace of Program to be the same one as Form1
Elmishh
ElmishhOP2y ago
the original namespace wasnt Form1
reflectronic
reflectronic2y ago
when you do Application.Run(new Form1());, it's looking for a thing called Form1 in your program it's trying to look in the namespace WindowsFormsApp2 for Form1
Elmishh
ElmishhOP2y ago
im following a guide from microsoft 1 to 1 and its not working
reflectronic
reflectronic2y ago
but you moved it, presumably. it's in a different namespace now so you need to change namespace WindowsFormsApp2 to namespace HelloWorld that way it will find Form1 in HelloWorld, since that is where you put it
Elmishh
ElmishhOP2y ago
oh
Want results from more Discord servers?
Add your server