我正在尝试使用 c++/cli 代码从 ac# 调用非托管函数。
我有类似这样的代码:
MyFileWrapper MyFileWrapper::ReadMyFile(System::String ^fileName)
{
auto nativeMyFile=MyFile::ReadMyFile((char *)
System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(
fileName).ToPointer());
MyFileWrapper myFileWrapper=gcnew MyFileWrapper();
// code will be added to read information from native object and convert them to wrapper properties.
return myFileWrapper;
}
但我收到错误
Error 2 error C2440: 'return' : cannot convert from 'MyFileWrapper' to 'MyFileWrapper' MyFileWrapper.cpp
Error 1 error C3673: 'MyFileWrapper' : class does not have a copy-constructor MyFileWrapper.cpp
对于第一个错误,智能感知给我以下错误,它有更好的解释:
IntelliSense: no suitable user-defined conversion from "MyFileWrapper ^" to "MyFileWrapper" exists
有什么问题,我该如何解决?