系统出现异常:参数计数不匹配,未处理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的方法定义必须一致,如不一致,则会出现如上异常信息。


参数计数不匹配,未处理System.Reflection.TargetParameterCountException的更多相关文章

  1. 反射方法调用时:参数计数不匹配( parameter count mismatch )

    Invoke方法的参数当中有一个自己的object[],正好你传递的参数也是object[],这样的话invoke就会把你参数数组里面的第一个参数作为参数传递给你要调用的方法,于是就报错了. 解决问题 ...

  2. System.Reflection.Emit摘记

    动态类型在.net中都是用什么类型来表示的.程序集:System.Reflection.Emit.AssemblyBuilder(定义并表示动态程序集)构造函数:System.Reflection.E ...

  3. 基础命名空间:反射 using System.Reflection

    反射概念:       .Net的应用程序由几个部分:‘程序集(Assembly)’.‘模块(Module)’.‘类型(class)’组成,程序集包含模块 模块包含类型,类型又包含 成员,而反射提供一 ...

  4. “System.Reflection.AmbiguousMatchException”类型的异常在 mscorlib.dll 中发生

    错误提示: “System.Reflection.AmbiguousMatchException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理. 发现不明确的匹配. 问题原 ...

  5. 异常:“System.Reflection.Metadata”已拥有为“System.Collections.Immutable”定义的依赖项

    参考动态执行T4模板:https://msdn.microsoft.com/zh-cn/library/bb126579.aspx 我项目是.NET Framework 4.5控制台应用程序写的. 执 ...

  6. 【C#基础】System.Reflection (反射)

    在使用.NET创建的程序或组件时,元数据(metadata)和代码(code)都存储于"自成一体"的单元中,这个单元称为装配件.我们可以在程序运行期间访问这些信息.在System. ...

  7. 部署时,出现用户代码未处理 System.Security.Cryptography.CryptographicException 错误解决方法

    转载:http://www.cnblogs.com/jys509/p/4499978.html 在调用RSA加密的.pfx密钥时,在本地调试没有问题,可以布署到服务器,就会报以下的错误: 用户代码未处 ...

  8. System.Reflection.Assembly.GetEntryAssembly()获取的为当前已加载的程序集

    今天在使用System.Reflection.Assembly.GetEntryAssembly()获取程序集时,发现获取的程序集不全.原来是因为C#的程序集为延迟加载,此方法只获取当前已加载的,未加 ...

  9. System.Reflection.Emit学习

    C#反射发出System.Reflection.Emit学习 分享: 1 一.System.Reflection.Emit概述 Emit,可以称为发出或者产生.与Emit相关的类基本都存在于Syste ...

随机推荐

  1. CXF Service Interceptor请求,响应报文之控制台输出

    一:定义接口 @WebService(targetNamespace = "http://www.unionpay.com/client/appprovider", name = ...

  2. js遍历数组和遍历对象的区别

    <script> //----------------for用来遍历数组对象-- var i,myArr = [1,2,3]; for (var i = 0; i < myArr.l ...

  3. [经典] Best Time to Buy and Sell Stock

    这一系列求最优值的问题变种挺多 1. Say you have an array for which the ith element is the price of a given stock on ...

  4. MySQL表设计基础

    MySQL表设计关于blog数据库中建立所有表的sql语句<一.>sql语句中 约束概念constraint concept1.1 实体完整性entity integrity(主键--唯一 ...

  5. winform 分页 分类: WinForm 2014-05-16 15:30 257人阅读 评论(0) 收藏

    说明:(1)如果对分页的感兴趣的话,可以看一下我传的存储过程("SQL 存储过程 分页")               (2)分页,第一页.上一页,下一页.最后一页只调用点击(cl ...

  6. spring security 允许 iframe 嵌套

    spring security +spring boot框架, 允许 嵌套ifram :

  7. Ubuntu开机出现:Fontconfig warning:"/etc/fonts/conf.d/65-droid-sans-fonts.conf"的解决办法

    Ubuntu升级后可能会出现以下问题: Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line ...

  8. Android传感器概述(六)

    监视传感器事件 要监视原始的传感器数据,你须要实现两个通过SensorEventListener接口暴露的回调方法:onAccuracyChanged()和onSensorChanged().Andr ...

  9. 只有在配置文件中或 Page 说明会 enableSessionState 至 true 时刻,能够使用会话状态。另外,还要确保应用程序配置 // 段包含 System.Web.SessionSta

    首先,弄清楚我们的目的,我的目标是验证用户登录.那是,Session["userName"]!=null 在ok该 起初,我是这么写的,结果给出,提示如果上述错误标题,在调查的很长 ...

  10. Dapper Use For Net

    Dapper.Net by example januari 6, 2012 When the team behind StackOverflow released the mini-ORM Dappe ...