C# winform VS2008
有一个datagridview,检索时有数据的情况下正常,没数据的时候我用了一个messagebox.show("No Data Found")来提示
以前一直正常,都跑了一个月了。
今天早上突然在没数据的情况下出现错误,即运行到messagebox.show("No Data Found")时,提示框也不弹出来,直接跳到了catch(exception ex)
{}显示调用目标发生错误。请教各位,这是啥问题?我这里就一个简单的检索,然后没数据的时候弹出对话框提示一下。且以前都运行正常,在没有修改代码的情况下,为啥出现了“调用目标发生异常的”问题??

解决方案 »

  1.   

    呵呵,楼上等于没说
    我要调试有结果,就不来问了
    这问题从来没碰到过,就一个select * from table,连条件都没有的检索,只要判断一下有没有数据就行
    以前都正常。现在只要在没检索到数据的情况下就报这个错误
      

  2.   

    详细异常信息
    未处理 System.Reflection.TargetInvocationException
      Message="调用的目标发生了异常。"
      Source="mscorlib"
      StackTrace:
           在 System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           在 System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           在 System.Delegate.DynamicInvokeImpl(Object[] args)
           在 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
           在 System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
           在 System.Threading.ExecutionContext.runTryCode(Object userData)
           在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
           在 System.Windows.Forms.Control.InvokeMarshaledCallbacks()
           在 System.Windows.Forms.Control.WndProc(Message& m)
           在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
           在 System.Windows.Forms.Form.WndProc(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           在 System.Windows.Forms.SafeNativeMethods.MessageBox(HandleRef hWnd, String text, String caption, Int32 type)
           在 System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp)
           在 System.Windows.Forms.MessageBox.Show(String text)
           在 NECS.MainForm.Data_Search_Click(Object sender, EventArgs e) 位置 D:\柬埔寨\NECS\NECS\MainForm.cs:行号 262
           在 System.Windows.Forms.Control.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           在 System.Windows.Forms.Control.WndProc(Message& m)
           在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
           在 System.Windows.Forms.Button.WndProc(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.Run(Form mainForm)
           在 NECS.Program.Main() 位置 D:\NECS\Program.cs:行号 18
           在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.ArgumentException
           Message="参数无效。"
           Source="System.Drawing"
           StackTrace:
                在 System.Drawing.Image.get_Width()
                在 System.Drawing.Image.get_Size()
                在 NECS.MainForm.ShowDrawRectangle() 位置 D:\NECS\MainForm.cs:行号 397
           InnerException: