An unhandled exception of type 'System.NullReferenceException'

G

Guest

Hi, I hope I can find some help for this problem

IDE: Visual Studio.NET 2003 Developer Editio
Language: C#
Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll. Additional information: Object reference not set to an instance of an object.

Visual Studio's IDE is not allowing me to develop projects in C#... I've trying to create a simple Windows Forms project using Visual Studio.NET 2003 Enterprise Developer, and to code it using C#
As soon as I press F5, the exception is produced. Notice that I haven't placed any control on the form yet. And I haven't code anything. The only code that exists is the code-behind generated by Visual Studio

To be more precise, I'll describe the steps I've been performing

1) Select File>New>Project from Visual Studio IDE
2) Select C# as the language of preferenc
3) Select Windows Application
4) Click OK on the dialog form
5) Once the default window and code is generated..
6) Press F5

As it can be seen from the mentioned steps, I haven't coded anything neither inserted any control on the form. Just tried to run an empty Form, using the IDE's generated code. Of course, if any control is added to the form or something is coded, the exception is also produced

I'm tring to say that the exception is been produced by the code-behind generated. Not by anything added by me, since I haven't added anything

I'm pasting the code-behind in the following paragraphs to make it easy to see.
I would much appreciate any guide, help or suggestion to resolve this problem

=== Begining of cod
using System
using System.Drawing
using System.Collections
using System.ComponentModel
using System.Windows.Forms
using System.Data

namespace WindowsApplication1

/// <summary
/// Summary description for Form1
/// </summary
public class Form1 : System.Windows.Forms.For

/// <summary
/// Required designer variable
/// </summary
private System.ComponentModel.Container components = null

public Form1(

/
// Required for Windows Form Designer suppor
/
InitializeComponent()

/
// TODO: Add any constructor code after InitializeComponent cal
/


/// <summary
/// Clean up any resources being used
/// </summary
protected override void Dispose( bool disposing

if( disposing

if (components != null)

components.Dispose()


base.Dispose( disposing )


#region Windows Form Designer generated cod
/// <summary
/// Required method for Designer support - do not modif
/// the contents of this method with the code editor
/// </summary
private void InitializeComponent(

this.components = new System.ComponentModel.Container()
this.Size = new System.Drawing.Size(300,300)
this.Text = "Form1"

#endregio

/// <summary
/// The main entry point for the application
/// </summary
[STAThread
static void Main()

Application.Run(new Form1())



==== End of cod

Thank you very much in advance for your help.
 
R

Rick Winter

I can't reproduce this behavior. Perhaps you could post more information
as to the actual exception. i.e. Which object is null when it is being
accessed.

_Rick
--------------------
| Thread-Topic: An unhandled exception of type
'System.NullReferenceException'
| thread-index: AcPzT9a8IYy52dQURiur+t6Ma+ocsw==
| X-Tomcat-NG: microsoft.public.dotnet.general
| From: =?Utf-8?B?UmFmYWVs?= <[email protected]>
| Subject: An unhandled exception of type 'System.NullReferenceException'
| Date: Sat, 14 Feb 2004 15:11:12 -0800
| Lines: 98
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa07.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:124655
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi, I hope I can find some help for this problem.

IDE: Visual Studio.NET 2003 Developer Edition
Language: C#.
Problem: "An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll. Additional information: Object
reference not set to an instance of an object."

Visual Studio's IDE is not allowing me to develop projects in C#... I've
trying to create a simple Windows Forms project using Visual Studio.NET
2003 Enterprise Developer, and to code it using C#.
As soon as I press F5, the exception is produced. Notice that I haven't
placed any control on the form yet. And I haven't code anything. The only
code that exists is the code-behind generated by Visual Studio.

To be more precise, I'll describe the steps I've been performing:

1) Select File>New>Project from Visual Studio IDE.
2) Select C# as the language of preference
3) Select Windows Application.
4) Click OK on the dialog form.
5) Once the default window and code is generated...
6) Press F5.

As it can be seen from the mentioned steps, I haven't coded anything
neither inserted any control on the form. Just tried to run an empty Form,
using the IDE's generated code. Of course, if any control is added to the
form or something is coded, the exception is also produced.

I'm tring to say that the exception is been produced by the code-behind
generated. Not by anything added by me, since I haven't added anything.

I'm pasting the code-behind in the following paragraphs to make it easy to
see.
I would much appreciate any guide, help or suggestion to resolve this
problem.

=== Begining of code
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication12
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
==== End of code

Thank you very much in advance for your help.
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top