A
Andreas Wirén
Hi I'm a C# .NET newbie doing a minor school project but I'm getting a
strange error message.
'System.NullReferenceException' occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object."
As my references look I seem to be using the old framework(1.0.3705) for
this, but re-referencing to the newer framework(1.1.4322) dll's produces the
same error. This happens under all circumstances when I'm trying to compile
a fully managed project. Even from scratch when trying to just compile the
empty form this happens.
If you read the old thread I've included you can see that he changed his
sourcepath for the whole project to something that is not put in the
MyDocuments folders. I did exactly the same thing and it worked, the
question from me is WHY? All other apps (so far) compiles flawless, it's
only these C# Windows Applications Projects that fail.
Regards,
Andreas Wirén
OS : Windows XP Professional SP1 with all the recent hotfixes and updates.
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.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()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
http://groups.google.se/groups?hl=s...ideotron.net&rnum=6&prev=/groups?q=%22Applica
tion.Run(new%2BForm1())%253B%2522%2B%2522object%2Breference%2Bnot%2Bset%2522
%26hl%3Dsv%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D6FADa.54216%2524g33.74
9173%2540weber.videotron.net%26rnum%3D6
strange error message.
'System.NullReferenceException' occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object."
As my references look I seem to be using the old framework(1.0.3705) for
this, but re-referencing to the newer framework(1.1.4322) dll's produces the
same error. This happens under all circumstances when I'm trying to compile
a fully managed project. Even from scratch when trying to just compile the
empty form this happens.
If you read the old thread I've included you can see that he changed his
sourcepath for the whole project to something that is not put in the
MyDocuments folders. I did exactly the same thing and it worked, the
question from me is WHY? All other apps (so far) compiles flawless, it's
only these C# Windows Applications Projects that fail.
Regards,
Andreas Wirén
OS : Windows XP Professional SP1 with all the recent hotfixes and updates.
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.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()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
http://groups.google.se/groups?hl=s...ideotron.net&rnum=6&prev=/groups?q=%22Applica
tion.Run(new%2BForm1())%253B%2522%2B%2522object%2Breference%2Bnot%2Bset%2522
%26hl%3Dsv%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D6FADa.54216%2524g33.74
9173%2540weber.videotron.net%26rnum%3D6