By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,938 Members | 1,578 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,938 IT Pros & Developers. It's quick & easy.

An unhandled exception of type 'System.NullReferenceException'

P: n/a
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.
Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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?= <an*******@discussions.microsoft.com>
| Subject: An unhandled exception of type 'System.NullReferenceException'
| Date: Sat, 14 Feb 2004 15:11:12 -0800
| Lines: 98
| Message-ID: <20**********************************@microsoft.co m>
| 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.
|

Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.