Abdülber Kaya
Abdülber Kaya

Reputation: 149

C# Setting Form 2 as Startup

in c#, i want to set forum 2 as startup form from program.cs, but when i try to change the code piece below i get such an error

before changing:

static void Main()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

after changing:

static void Main()
    {

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form2());
    }

the error is : The type or namespace name 'Form2' could not be found (are you missing a using directive or an assembly reference?)

All my changes are to write "Form2" instead of "Form1"

Upvotes: 1

Views: 4780

Answers (1)

Arran
Arran

Reputation: 25056

According to your comments, your form Form2 lives within the Uploader namespace. If that is the entire namespace then:

At the top of Program.cs, add in:

 using Uploader;

or

If you are using Visual Studio, it has a handy feature that allows you to right-click on where the error occurs (the Application.Run line), and it will give you the option to automagically add in the using for you.

Upvotes: 3

Related Questions