I created a clean WindowsFormsApplication solution, added it ToolStripto the main form, and placed one button on it. I added also OpenFileDialog, so the event Clickfor ToolStripButtonlooks like this:
private void toolStripButton1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}
I have not changed any other properties or events.
The funny thing is that when I double-click on the button ToolStripButton(the second click should be quite quick before opening the dialog), cancel both dialogs (or select a file, it does not matter) and then click in the client area of the main form, the NullReferenceExceptionapplication will fail (error data is attached at the end of the message). Note that the event is Clickimplemented, but DoubleClicknot.
What is even more strange is that when replaced OpenFileDialogwith any custom form, blocks ToolStripButtoncan be double clicked.
I am using VS2008 with .NET3.5 on Windows 7 Professional (from MSDNAA) with the latest updates. I have not changed many parameters in VS (only fontsize, workspace folder and line numbering).
- , ? 100% , ?
, , OpenFileDialog.ShowDialog(), ( ). ?
:
System.NullReference
Message = " ."
= "System.Windows.Forms"
StackTrace:
System.Windows.Forms.NativeWindow.WindowClass.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG & msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32, Int32 pvLoopData)
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner( Int32, ApplicationContext)
System.Windows.Forms.Application.ThreadContext.RunMessageLoop( Int32, ApplicationContext)
System.Windows.Forms.Application.Run(Form mainForm)
WindowsFormsApplication1.Program.Main() w C:\Users\Marchewek\Desktop\Workspaces\VisualStudio\WindowsFormsApplication1\Program.cs: 20
System.AppDomain._nExecuteAssembly ( , String [] args)
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String [] args)
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
System.Threading.ThreadHelper.ThreadStart_Context ( )
System.Threading.ExecutionContext.Run( , ContextCallback, )
System.Threading.ThreadHelper.ThreadStart()
InnerException: