Kyle Luchinski
Kyle Luchinski

Reputation: 153

Type or namespace Window cannot be found

I am confused as to why a Window will not appear with the below code. Am I missing an import?

using System.Text;
using System.Xml;
using System.Windows;
using System;
using System.Windows.Forms;
using System.IO;
using System.Threading;

    public class Program {

    public Window mainWindow;

    static void main() {

        // Create the application's main window
        mainWindow = new Window();
        mainWindow.Title = "Enter SN";
        mainWindow.Show();
    }
    }

Upvotes: 1

Views: 3126

Answers (1)

Stealth Rabbi
Stealth Rabbi

Reputation: 10346

You want to run your Window via an Application.Run() call. Your current code will not fire it off on a standard windows message loop, which is required.

Remove your Show() call and replace it with:

Application.Run(mainWindow);

To be even simpler, if you set your title as your wish on your WinForms designer, your main can be a single line:

Application.Run(new Window());

Also, you have many unnecessary using statements. These statements aren't a real problem, just unnecessary and confusing.

Upvotes: 3

Related Questions