0
我有一個小問題,我會先解釋一下。我正嘗試將使用C++ dll的C#代碼轉換爲C++代碼,因此我的C++應用程序可以使用C#dll。以下是C#代碼C++/CLI:無法轉換參數
private void USB_OnSpecifiedDeviceRemoved(object sender, EventArgs e)
{
this.DevicePresent = false;
}
this.USB.OnSpecifiedDeviceRemoved += new EventHandler(this.USB_OnSpecifiedDeviceRemoved);
以下的部分是我的C++轉換
usb.OnSpecifiedDeviceRemoved += System::EventHandler(this->USB_OnSpecifiedDeviceRemoved(nullptr,nullptr));
void MissileLauncher::USB_OnSpecifiedDeviceRemoved(System::Object sender, System::EventArgs e)
{
}
當我運行我的C++代碼,我收到以下錯誤
1>------ Build started: Project: CallToCSharp, Configuration: Debug Win32 ------
1> MissileLauncher.cpp
1>MissileLauncher.cpp(109): error C2664: 'MissileLauncher::USB_OnSpecifiedDeviceRemoved' : cannot convert parameter 1 from 'nullptr' to 'System::Object'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>MissileLauncher.cpp(109): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
爲什麼發生這種情況?有任何想法嗎?
什麼樣的幫助很大是這個!真棒! – 2013-05-11 17:33:02