473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

System.NullReferenceException in System.Windows.Forms......

Hi,

I have the folowing exception

Exception : System.NullReferenceException: Object reference not set to
an instance of an object.
00000019 3:30:48 PM [260] at
System.Windows.Forms.UnsafeNativeMethods.GetOpenFi leName(OPENFILENAME_I
ofn)
00000020 3:30:48 PM [260] at
System.Windows.Forms.OpenFileDialog.RunFileDialog( OPENFILENAME_I ofn)
00000021 3:30:48 PM [260] at
System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
00000022 3:30:48 PM [260] at
System.Windows.Forms.CommonDialog.ShowDialog()
00000023 3:30:48 PM [260] at
UI.Commands.File.OpenPackage(Object sender, EventArgs e) in
........\StartUp\Commands\File.cs:line 155
00000024 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuCommand.OnClick(EventArg s e)
00000025 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuControl.GenerateShortcut (Shortcut sc,
MenuCommandCollection mcc)
00000026 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuControl.GenerateShortcut (Shortcut sc,
MenuCommandCollection mcc)
00000027 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuControl.PreFilterMessage (Message& msg)
00000028 3:30:48 PM [260] at
System.Windows.Forms.ThreadContext.System.Windows. Forms.UnsafeNativeMethods+IMsoComponent.FPreTransl ateMessage(MSG&
msg)
00000029 3:30:48 PM [260] at
System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
00000030 3:30:48 PM [260] at
System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32 reason,
ApplicationContext context)
00000031 3:30:48 PM [260] at
System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason,
ApplicationContext context)
00000032 3:30:48 PM [260] at
System.Windows.Forms.Application.Run(Form mainForm)
the exception is thrown in the following code in try section

OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.DefaultExt = "xxxx";
openFileDialog.Title = "xxxxxxx";
openFileDialog.InitialDirectory = Environment.CurrentDirectory;
openFileDialog.FileName = "";

try
{
dialogResult = openFileDialog.ShowDialog();
}
catch (NullReferenceException ex)
{
//log exception
}

The code is called on an open selection from a menu.
It throws the exception randomly, meaning that I can pres open 100
times and get no exception or only 3 times an get it. The try catch
doesn't solve the problem because all the program freezes.
I found on google that this exception appears in other programs but no
solution to solve the problem
(http://aquaxp.com/news/index.php?p=22 or
http://www.evilgeniuschat.com/viewto...b36fe56cf6ae60)

Nov 17 '05 #1
2 5465
hi,

I just tested your code ( copy & paste it ) and it did work. Does it happen
with any file or just with some especific one?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"fperfect13" <fe****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,

I have the folowing exception

Exception : System.NullReferenceException: Object reference not set to
an instance of an object.
00000019 3:30:48 PM [260] at
System.Windows.Forms.UnsafeNativeMethods.GetOpenFi leName(OPENFILENAME_I
ofn)
00000020 3:30:48 PM [260] at
System.Windows.Forms.OpenFileDialog.RunFileDialog( OPENFILENAME_I ofn)
00000021 3:30:48 PM [260] at
System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
00000022 3:30:48 PM [260] at
System.Windows.Forms.CommonDialog.ShowDialog()
00000023 3:30:48 PM [260] at
UI.Commands.File.OpenPackage(Object sender, EventArgs e) in
.......\StartUp\Commands\File.cs:line 155
00000024 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuCommand.OnClick(EventArg s e)
00000025 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuControl.GenerateShortcut (Shortcut sc,
MenuCommandCollection mcc)
00000026 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuControl.GenerateShortcut (Shortcut sc,
MenuCommandCollection mcc)
00000027 3:30:48 PM [260] at
Crownwood.Magic.Menus.MenuControl.PreFilterMessage (Message& msg)
00000028 3:30:48 PM [260] at
System.Windows.Forms.ThreadContext.System.Windows. Forms.UnsafeNativeMethods+IMsoComponent.FPreTransl ateMessage(MSG&
msg)
00000029 3:30:48 PM [260] at
System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
00000030 3:30:48 PM [260] at
System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32 reason,
ApplicationContext context)
00000031 3:30:48 PM [260] at
System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason,
ApplicationContext context)
00000032 3:30:48 PM [260] at
System.Windows.Forms.Application.Run(Form mainForm)
the exception is thrown in the following code in try section

OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.DefaultExt = "xxxx";
openFileDialog.Title = "xxxxxxx";
openFileDialog.InitialDirectory = Environment.CurrentDirectory;
openFileDialog.FileName = "";

try
{
dialogResult = openFileDialog.ShowDialog();
}
catch (NullReferenceException ex)
{
//log exception
}

The code is called on an open selection from a menu.
It throws the exception randomly, meaning that I can pres open 100
times and get no exception or only 3 times an get it. The try catch
doesn't solve the problem because all the program freezes.
I found on google that this exception appears in other programs but no
solution to solve the problem
(http://aquaxp.com/news/index.php?p=22 or
http://www.evilgeniuschat.com/viewto...b36fe56cf6ae60)

Nov 17 '05 #2
It doesn't seem to depend on some specific file. The error appears
randomly ,usualy very rare (after 50 -60 open file) and freezes the
application. I suppose it depends on some factors but I can't determine
the exact circumstances to reproduce it at will. I don't think you can
reproduce it because in a simple program it seems to work fine. What I
mean is that this error apears in some circumstances generated in more
complex programs under "stress tests".

Nov 17 '05 #3

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

Similar topics

3
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...
1
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...
1
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...
0
by: sarah | last post by:
Using .NET C# installed Framework 1.1 with Service Pack 1 I have a MDI application in C# that contains 3 different forms. Form 1 has several controls one of which is a DataGrid control that...
2
by: Greg Bacchus | last post by:
Hi, I'm getting an exception that really has me stumped. It's sporadic at best, it's only happened a handful of times. This particular time it happened when the user pressed 'Alt-S' to save the...
1
by: Ghada Ayed via DotNetMonster.com | last post by:
Hello every body, please help me in this problem i have written the following C# code in VS.Net and when i run the window application i have got 'System.NullReferenceException' so please if...
2
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...
6
by: Chuck | last post by:
I created a VB.net app that opens a current excel workbook, puts some data in it and saves it. This works fine on all XP machines. But I am getting an error on win 98 machines. here a portion...
2
by: Graeme Neath | last post by:
I'm having a very bizarre problem. I have a vb.net application which uses the ESRI MapObjects 2.2 component (unmanaged code). When I use the MapObjects built-in function 'CopyMap' to copy the map...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.