类型为"System.Reflection.TargetParameterCountException"的未处理异常
An unhandled exception of type 'System.Reflection.TargetParameterCountException'
我创建了一个BeginInvoke,这样我就可以从非UI线程写入文本框。线程A调用一个委托,该委托在线程A的上下文中运行testFunc。testFunc然后执行BeginInvoke,它运行空函数ControlBoxDelegateMethod。如果删除了BeginInvoke行,则程序将运行。但如果它被保留,我会得到以下异常:
mscorlib.dll中出现"System.Reflection.TargetParameterCountException"类型的未处理异常。其他信息:参数计数不匹配。
private:
//delegate void ControlBoxDelegate(Label^ myControl,int whichControl);
void ControlBoxDelegateMethod(Label^ myControl,int whichControl)
{
// myControl->Text = "Test!!!!!!!";
}
public:
void testFunc()
{
int which = 3;
local_long_textBox->BeginInvoke(gcnew ControlBoxDelegate
(this,&Form1::ControlBoxDelegateMethod),which);
}
有人能告诉我我在这里做错了什么吗?谢谢
ControlBoxDelegateMethod
接受两个参数(Label^
和int
),但您只传递一个参数(名为which
的int
)。您缺少第一个参数。
所以,它可能应该是这样的:
local_long_textBox->BeginInvoke(gcnew ControlBoxDelegate(this,&Form1::ControlBoxDelegateMethod), your_label, which);
相关文章:
- 在c++中实现LinkedList时,应出现未处理的错误
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- 在信号处理程序中捕获C++未处理的异常并恢复应用程序
- 在C++程序中使用的迭代器中未处理的异常
- 在 ******.exe 中0x00000000772CA267 (ntdll.dll) 处未处理的异常:0xC0000
- 未处理的异常与 cudaMemcpy2D
- 处理未处理的异常更改C++
- for 循环中未处理的异常
- VisualC++ 2010 有没有办法找出有关未处理异常错误的更多详细信息
- 为什么此代码导致未处理的异常失败
- 瓦尔格林德:注意到但未处理的国际奥克特尔;是否有必要处理以及如何找到?
- 在OpenCV_core310.dll中使用findContours函数时,OpenCV引发未处理的异常
- 0x0F50DF58:0xC0000005:访问冲突读取位置0x0047CA04时未处理的异常
- 使用 getline 时未处理的异常
- 错误 : 异常 : 引发未处理的异常: 读取访问冲突.0xDDDDDDDD临时温度
- 核心消息传递中未处理的异常.dll在程序关闭期间
- 在 Hello World.exe 中0x0F828F0E (ucrtbased.dll) 处未处理的异常: 0xC00
- 从向量中删除元素时未处理的异常
- QML:多个键按 /发布后未处理一些键
- C++ 程序中双链表的未处理异常