473,698 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.NullRefe renceException occurred in

Hi I'm a C# .NET newbie doing a minor school project but I'm getting a
strange error message.

'System.NullRef erenceException ' 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.3 705) for
this, but re-referencing to the newer framework(1.1.4 322) 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.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;

namespace WindowsApplicat ion1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

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

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
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 InitializeCompo nent()
{
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHan dler(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(obje ct sender, System.EventArg s e)
{

}
}
}

http://groups.google.se/groups?hl=sv...3D%2522Applica
tion.Run(new%2B Form1())%253B%2 522%2B%2522obje ct%2Breference% 2Bnot%2Bset%252 2
%26hl%3Dsv%26lr %3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D6FAD a.54216%2524g33 .74
9173%2540weber. videotron.net%2 6rnum%3D6
Nov 15 '05
11 3742
With "Compile - Error!" I mean it's not giving me an error-free compile. The
..exe file is still created and I suppose that means it's an run-time error.
However, I found something very funny, if I just move the file (the "not
error free exe") down one folder in the hierarchy (using Explorer) the file
executes flawless.

Files on Machine1:

c:\documents and settings\Andrea s.ATHLON1\My Documents\Visua l Studio
Projects\Window sApplication3\b in\Debug\test1. exe
c:\documents and settings\Andrea s.ATHLON1\My Documents\Visua l Studio
Projects\Window sApplication3\b in\Debug\test2. exe

test1.exe is compiled on Machine1 without any errors, test2 is compiled on
Machine2 but with errors.
test1.exe can be executed anywhere on Machine1 but it gives me an exception
on Machine2 when executed from the above specific dir.
test2.exe works in the exact same mysterious ways as test1.exe but is
compiled with errors as I said earlier.

But if I just move any of the two exe files to another dir, say
c:\documents and settings\Andrea s.ATHLON1\My Documents\Visua l Studio
Projects\Window sApplication3\b in\test1.exe

Then the file executes without a hitch :-P

Haha, this sure is a mess but I hope you understand.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> skrev i meddelandet
news:MP******** *************** @msnews.microso ft.com...
Andreas Wirén <an*****@clan.d cs.se> wrote:
Sorry if I was confusing you :-)

Machine1 (not the broken one) : Compile - OK! , Executing - OK!
Machine2 (the broken one) : Compile - Error!, Executing - Error!
When you say "Compile - Error!" are you now saying that you *do* get an
error at compile-time?
Thanks for your time btw! It's not really that big issue but it's annoying
not being able to save documents/projects to whereever you want.


It's also *only* when you save the project in My Documents somewhere
that you get the problem, yes?

It does sound highly bizarre to me.

Out of interest, what happens when you have the project in My Documents
but compile the source code from the command line?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #11
Andreas Wirén <an*****@clan.d cs.se> wrote:
With "Compile - Error!" I mean it's not giving me an error-free compile.
So it's giving you an error at compile-time? What error is that?
The .exe file is still created and I suppose that means it's an run-time error.
However, I found something very funny, if I just move the file (the "not
error free exe") down one folder in the hierarchy (using Explorer) the file
executes flawless.


Okay, that's very strange - I'm entirely baffled now, I'm afraid :(

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9135
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in system.windows.forms.dll
1
5975
by: gregory_may | last post by:
This code seems to "work" but I get the following errors: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll then this one: An unhandled exception of type 'System.ExecutionEngineException' occurred in system.windows.forms.dll Anyone know how to either trap these errors or prevent them from happening?
1
536
by: Rafael | last post by:
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...
7
3994
by: David Elliott | last post by:
I have created an application that will dynamically load other DLLs (plugins). The new plugin is a winform with an embedded IE Browser. I am wanting to have the form to run in its own thread. This would allow for other plugins and the main application to be free to do other work. I have written a little TestDriver for the plugin and am having some difficulty. If I don't use threads everything works just fine. If I do use threads, upon...
3
1730
by: msnews.microsoft.com | last post by:
actaully the code i have written below is pretty simple and short. no idea why it terminate at run-time with "An unhandled exception of type 'System.NullReferenceException' occurred" Thank you ---code below--- using System;
2
7828
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll ...
2
2774
by: sxiao | last post by:
Hi, there I got a NullReferenceException when there are more than one users trying to open the same page at the same time. The senerio is: Two users logged into the web application using the Windows domain user account and tried to open the same page which has the databasde query code. When the two user tried to open the same page at the same time, there is a runtime error messsage showing as follows:
9
3174
by: Supra | last post by:
i got error 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.. Namespace PirateChat <========== error occurred in here Public Class mainPirateChat
0
2311
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the Edit feature of the DataGridView. I have set several of the BoundField elements of the DataGridView to ReadOnly="True". When I attempt to use the Edit feature to UPDATE the rows in the DataGridView I get a System.NullReferenceException for...
3
22370
by: GS | last post by:
why am i getting A first chance exception of type 'System.NullReferenceException' occurred in myapp.exe below? and what can i do get rid of it? Private Function getPrefxType() As String If bSkipGetListBOxComboBoxValue Then Return "" Try
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.