业务伙伴已经创建了一个用C ++编写的DLL。
我们的合作伙伴描述了可以通过在C ++中使用此代码来访问C ++ DLL方法(我们已经过测试,并且它在使用C ++编写的代码中非常有效)
create_func_ptr createInstance = (create_func_ptr)(GetProcAddress(hdl, "createReader"));
LudvigInterface* ludvigInterface = createInstance();
if (ludvigInterface)
{
bool isRunning = ludvigInterface->isRunning();
destroy_func_ptr closeInstance = (destroy_func_ptr)(GetProcAddress(hdl, "closeReader"));
closeInstance(ludvigInterface);
}
但我们的挑战是我们希望在C#中做同样的事情。
我们可以通过DLLImport语句打开DLL,一切运行良好,直到我们尝试访问isRunning方法。
class Program
{
[DllImport(@"\Libraries\LudvigImplementation.dll")]
private static extern IntPtr createReader();
[DllImport(@"\Libraries\LudvigImplementation.dll")]
private static extern bool isRunning();
static void Main(string[] args)
{
IntPtr LudvigInterfacePtr = createReader(); //this line runs well
var a = isRunning(); //This line gives a System.EntryPointNotFoundException: 'Unable to find an entry point named 'isRunning' in DLL LudvigImplementation.dll'
}
}
我们如何解决这个问题?我们如何在C#中访问DLL isRunning方法?
非常感谢
更新2.可能在13:31 CET:
我对LudvigInterface的外观有些疑问 这是(LudvigInterface.h)
class LudvigInterface
{
public:
virtual bool isRunning() = 0;
virtual char* getVersion() = 0;
};
再次感谢