我使用 UnmanagedExports 公开了两个函数 getStatus() 和 checkStatus()。我可以成功地将它们与 C++ 代码分开调用。但是当我从第二个函数 checkStatus() 内部调用第一个函数 getStatus() 时,我得到了 MissingMethodException。以下独立函数的代码工作正常:
[DllExport(ExportName = "GetStatusMethod", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string getStatus([MarshalAs(UnmanagedType.LPWStr)]string Url)
{
string status;
//performing some action
return status;
}
[DllExport(ExportName = "CheckStatusMethod", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string checkStatus([MarshalAs(UnmanagedType.LPWStr)]string someStr)
{
string status;
//performing some action
return status;
}
以下抛出 MissingMethodException:
[DllExport(ExportName = "GetStatusMethod", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string getStatus([MarshalAs(UnmanagedType.LPWStr)]string Url)
{
string status;
//performing some action
return status;
}
[DllExport(ExportName = "CheckStatusMethod", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string checkStatus([MarshalAs(UnmanagedType.LPWStr)]string someStr)
{
return getStatus();// throws MissingMethodException
}
如何从 c# 中的另一个公开函数中调用一个函数(使用 UnmanagedExports 公开)?