C
C#16mo 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
Elmishh16mo ago
anyone?
Shinigami
Shinigami16mo ago
Make sure to include the required assemblies System.Windows.Forms
reflectronic
reflectronic16mo ago
and changing namespace [???] to something else
the problem is that you did this you can't
Elmishh
Elmishh16mo ago
why cant i
reflectronic
reflectronic16mo ago
well, yo ushould be able to make it work, let me try something
Elmishh
Elmishh16mo 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
Elmishh16mo ago
and im getting
Elmishh
Elmishh16mo 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
reflectronic16mo ago
well, you changed the namsespace so it can't find new Form1() anymore. you moved it
Elmishh
Elmishh16mo ago
?
reflectronic
reflectronic16mo ago
you need to change the namespace of Program to be the same one as Form1
Elmishh
Elmishh16mo ago
the original namespace wasnt Form1
reflectronic
reflectronic16mo 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
Elmishh16mo ago
im following a guide from microsoft 1 to 1 and its not working
reflectronic
reflectronic16mo 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
Elmishh16mo ago
oh
Want results from more Discord servers?
Add your server
More Posts