An unhandled exception of type 'System.NullReferenceException'

G

Guest

I'm getting the following error trying to run a program written in C# (or in VB) from Visual Studion.NET 2003. I'm just pressing the F5 (start) key to run the application. It's happening with both languages.

"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.

Thank you very much in advance.
 
J

jim

Hi Rafael, can you post your code?

jim
Rafael said:
I'm getting the following error trying to run a program written in C# (or
in VB) from Visual Studion.NET 2003. I'm just pressing the F5 (start) key to
run the application. It's happening with both languages.
"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."
 
G

Guest

Thank you for your attention, Jim. I'll post the code later today. I'm not in my computer this time, so I don't have the code handly.

However, let me tell you that I did not write any line of code. Not even inserted a control on the form. The error came up from pure C# (and VB) generated code. I saw a problem somehow like this posted on Microsoft's Knowledge Base; but I did not pay too much attention to it because I saw it was related to version 2002 of Visual Studio. In my case, I'm in Visual Studio 2003.

The wierdest thing is that this is just happening... For your information: this is a re-installation of Visual Studio 2003 on a new computer. I've had Visual Studio 2003 since its arrival and this never happened before... I upgraded from Visual Studio 2002 to 2003 last year when the new version came up. All the time, on the old computer, the installation worked really fine.

Anyhow, I'll take a look at the mentioned article again to see what I find out and, later, I'll post the code.

Thanks again for your attention.
Rafael
 
G

Guest

As I said, Jim, I'm posting the code for the program that is failing with the mentioned error. You can see in it that it's just the code generated by Visual Studio when F5 is pressed.

Anyway, I was speaking with some other colleagues and there were speculations about a wrong installation...
Which is precisely what I'm going to do. They recommended to unistall the framework and visual studio, and install them again. I think it's a good idea and it's the thing I'll most likely do.

Here is the code. Please, take a look at it and feel free to post any comment. Thank you again for your attention and, please, let me know if you have any other idea.

Regards.

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

namespace TheOtherProject
{
/// <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());
}
}
}
 

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