Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Lesson 11 "Hello WinForm" won't compile

Errors are:
System.Windows.Forms;
System.Drawing;

The type of namespace "Windows" does not exist in the class or namespace "System"(are you missing an assembler reference)?

The type of namespace "Drawing" does not exist in the class or namespace "System"(are you missing an assembler reference)?

Code:

using System;
using System.Windows.Forms;
using System.Drawing;

namespace CSharpSchool
{
public class test
{
static void Main()
{
Application.Run(new MyWindow());
}
}

class MyWindow : Form
{
public MyWindow() : base()
{
this.Text = "My First Windows C# Windows Application";
this.Size = new Size(300, 300);

Label lblGreeting = new Label();
lblGreeting.Text = "Hello WinForm";
lblGreeting.Location = new Point(100, 100);

this.Controls.Add(lblGreeting);
}
}
}

Comments

  • frazrasheedfrazrasheed Member Posts: 18
    Hi,

    Infact, there is no error. What you need is to just add the two references 1. System.Windows.Forms.dll and 2. System.Drawing.dll from Visual Studio.Net's Solution Explorer's Reference's Add Reference Option. If I did not mention it in the lesson, i will add it soon

    Thanks and Regards,
    Faraz


    : Errors are:
    : System.Windows.Forms;
    : System.Drawing;
    :
    : The type of namespace "Windows" does not exist in the class or namespace "System"(are you missing an assembler reference)?
    :
    : The type of namespace "Drawing" does not exist in the class or namespace "System"(are you missing an assembler reference)?
    :
    : Code:
    :
    : using System;
    : using System.Windows.Forms;
    : using System.Drawing;
    :
    : namespace CSharpSchool
    : {
    : public class test
    : {
    : static void Main()
    : {
    : Application.Run(new MyWindow());
    : }
    : }
    :
    : class MyWindow : Form
    : {
    : public MyWindow() : base()
    : {
    : this.Text = "My First Windows C# Windows Application";
    : this.Size = new Size(300, 300);
    :
    : Label lblGreeting = new Label();
    : lblGreeting.Text = "Hello WinForm";
    : lblGreeting.Location = new Point(100, 100);
    :
    : this.Controls.Add(lblGreeting);
    : }
    : }
    : }
    :

Sign In or Register to comment.