0
對我來說這似乎很奇怪。所有的定義都符合,但似乎在輸入array<Object^>^
時調用函數時出現問題。這裏是我的簡單代碼:System.Reflection.TargetParameterCountException'發生在System.Windows.Forms.dll
void WriteCOMPortPannel(array< String^>^){ \\ Do something};
delegate void WriteCOMPortDelegate(array< String^>^);
array <String^ > ^COM_PORTS = this -> SerialPort ->GetPortNames();
this->Invoke (gcnew WriteCOMPortDelegate(this, &MainForm::WriteCOMPortPannel), COM_PORTS);
在C#中的解決方案是:
this->Invoke (MyDeligate , New Object() COM_PORTS);.
什麼C++ \ CLI?是否有任何類型不匹配?
很好。謝謝 ! –
另一個問題,爲什麼在另一個線程中調用這個 - > SerialPort-> GetPortNames()時沒有出現錯誤? 要了解更多信息,我知道SerialPort類不支持調用! –
'SerialPort'類不是一個控件,所以它可能不是單線程綁定的(這意味着它不需要*'Invoke')。 – Medinoc