" System.Reflection.TargetInvocationException"在运行单元测试用例时发生 [英] "System.Reflection.TargetInvocationException" occurs while running unit test cases

查看:132
本文介绍了" System.Reflection.TargetInvocationException"在运行单元测试用例时发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


 


我创建了一个自定义控件为对照维护了近2000个单元测试用例。


每个测试用例中使用的对象都被处理掉了正确。


 


问题:


 


以下运行单元测试用例时会出现异常。


 


 System.Reflection.TargetInvocationException:调用目标抛出了异常。 
System.ComponentModel.Win32Exception:附加到系统的设备在System.RuntimeMethodHandle.InvokeMethod(对象目标,Object []参数,签名sig,布尔构造函数)中运行
不起作用
at System .Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object []参数,Object []参数)
在System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object []参数,CultureInfo文化) System.Reflection.MethodBase.Invoke(对象obj,Object []参数)
$ / pre>


系统。 ComponentModel.Win32Exception:创建窗口句柄时出错。 
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)





 


我无法找出这些异常的根本原因。


请为此提供宝贵的建议。


提前致谢。

解决方案


根据您的描述,您的问题与单元测试更相关。这个论坛正在讨论并询问有关Windows窗体和ClickOnce的问题,我将把这个帖子移到相应的论坛:

Visual Studio单元测试论坛
获取专门信息。


感谢您的理解。


问候,


Frankie


Hi All,

 

I have created a custom control and maintains nearly 2000 unit testcases for the control.

The objects used in the each test cases were disposed properly.

 

Problem:

 

The below exceptions occurs randomly while running the unit test cases.

 

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
System.ComponentModel.Win32Exception : A device attached to the system is not functioning
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)


System.ComponentModel.Win32Exception: Error creating window handle.
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)


 

I can't able figure out the root cause for these exceptions.

Please provide your valuable suggestions for this.

Thanks in advance.

解决方案

Hi,

According to your description, your issue is more related about Unit Test. And this forum is discussing and asking questions about the Windows Form and ClickOnce, I will move this thread to corresponding forum: Visual Studio Unit Testing Forum for dedicated information.

Thank you for your understanding.

Regards,

Frankie


这篇关于" System.Reflection.TargetInvocationException"在运行单元测试用例时发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆