469,933 Members | 2,534 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,933 developers. It's quick & easy.

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 5133
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Terrence | last post: by
1 post views Thread by Ghada Ayed via DotNetMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.