• 参数计数不匹配,未处理System.Reflection.TargetParameterCountException


    系统出现异常:参数计数不匹配,未处理System.Reflection.TargetParameterCountException,
    系统会显示如下的异常信息,但异常信息往往与实际异常位置差十万八千量:

    未处理 System.Reflection.TargetParameterCountException
      Message=参数计数不匹配。
      Source=mscorlib
      StackTrace:
           在 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.UserControl.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(ApplicationContext context)
           在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           在 PCMax.Main.My.MyApplication.Main(String[] Args) 位置 17d14f5c-a337-4978-8281-53493378c1071.vb:行号 81
           在 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: 

    根据调试的实际情况显示,此异常是在使用Invoke调用时,没有正确匹配参数数量,因为Invoke或BeginInvoke方法的参数数量是可变的,所以在编译阶段根本不会出现编译错误,但在程序正式执行时,又要求目标调用方法与Delegate的方法定义必须一致,如不一致,则会出现如上异常信息。


  • 相关阅读:
    SIP头域说明
    android.os.NetworkOnMainThreadException异常
    "Only the original thread that created a view hierarchy can touch its views"引发的思考_Handler的使用
    sip命令与音视频rtp通话完整流程分析
    在Windows下搭建Android开发环境(摘自百度经验)
    jquery dialog 打开的时候自动聚焦解决方法
    对于数组(字符串)slice方法的总结
    SWIFT语言中的泛型编程 【GENERIC】【PART 2】
    手动调用playground的XCPCaptureValue展示Swift过程数据
    Swift语言相关资源贴
  • 原文地址:https://www.cnblogs.com/wene/p/4668830.html
Copyright © 2020-2023  润新知