class IQuoteApi
{
public:
//API函数
virtual bool __cdecl Open(TAddressField& addr) = 0;
virtual void __cdecl Close() = 0;
virtual bool __cdecl IsOpen() = 0;
};
extern "C"
{
//认证函数 认证码 针对每个开发商 一个
bool __cdecl CertApi(TCertInfoType cert, TLogPathType path);
}
C#代码如下:
[DllImport("Api.Dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool CertApi(string cert,string path);
[DllImport("Api.Dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int Close();
bool certInfo;
certInfo = CertApi("sdfsasfwer", "asdfdf");
int c;
c = Close();
运行报错:
无法在 DLL“Api.Dll”中找到名为“Close”的入口点。
使用反编译工具PE Explorer查看入口点没有仅仅存在CertApi,未找到Open、Close、IsOpen,
由此是否可以得到结论未声明extern "C"的C++将不会生成函数入口?
请问使用C#调用C++DLL是不是非得声明extern "C"才能被C#调用到?若未申明怎样才能调用到?