获取系统条目异常 [英] Getting a System Entry Exception
本文介绍了获取系统条目异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个本地库,如下所示。
Hello.h:
I have a native library written as below.
Hello.h:
#include<iostream>
using namespace std;
class __declspec(dllexport) Hello
{
public:
int PrintHello(char* str);
};
Hello.cpp
Hello.cpp
#include<iostream>
#include "Hello.h"
using namespace std;
int Hello::PrintHello(char* str)
{
cout<<"Hello "<< str <<endl;
return 0;
}
然后写了一些Exposing函数
API .h
then wrote some Exposing function
API.h
#include<iostream>
#include"Hello.h"
__declspec(dllexport) Hello* APICreateHello();
__declspec(dllexport) void APIDestroyHello();
API.cpp:
API.cpp:
#include<iostream>
#include "API.h"
extern "C" __declspec(dllexport) Hello* __cdecl APICreateHello(char* str)
{
return new Hello();
}
extern "C" __declspec(dllexport) void APIDestroyHello(Hello* obj)
{
delete obj;
}
Dumpbin导致APICreateHello和APIDestroyHello原样。没有姓名错误。
尝试使用C#main进行访问,但导致EntryPointException。
Dumpbin results in APICreateHello and APIDestroyHello as it is. there is no Name mangling.
Tried accessing using C# main as below but results in EntryPointException.
public class MyCustomDLLWrapper
{
// extern "C" MYCUSTOMDLL_API int AddNumbers(int x, int y);
[DllImport("TestLib.dll",EntryPoint = "APICreateHello")]
public static extern IntPtr APICreateHello(string str);
}
namespace TestManagedApp
{
class Program
{ public static int Main(string[] args)
{
IntPtr x = MyCustomDLLWrapper.APICreateHello("Pavan");
return 0;
}
}
}
请帮助。在此先感谢
Please help. Thanks in advance
推荐答案
我已经使用 __ stdcall
构建了这些项目,如上所述,它可以工作,到目前为止就这样。我让你继续处理剩下的问题。
I have built these projects using __stdcall
as noted above, and it works, as far as it goes. I leave you to work on the remaining issues.
这篇关于获取系统条目异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文