首页 新闻 搜索 专区 学院

P/Invoke 的 产生了 EntryPointNotFoundException

0
悬赏园豆:20 [待解决问题]

最近在封装一个dll文件,使得C#能够直接调用这个dll文件里的函数,我按着p/invoke的要求进行了设置。但是在调用的时候去产生了异常。

dll中定义了如下:

#ifdef OPESDK_EXPORTS
#define OPESDK_API __declspec( dllexport )
#define OPESDK_APICALL __stdcall

#elif defined(OPESDK_LIB)
#define OPESDK_API
#define OPESDK_APICALL

#else
#define OPESDK_API __declspec( dllimport)
#define OPESDK_APICALL __stdcall
#endif

OPESDK_API HI_S32 OPESDK_APICALL OPESDK_Initialize(OUT OPEHANDLE
*ppHandle);

OPESDK_API HI_S32 OPESDK_SetDecCallBack(IN OPEHANDLE pHandle,
IN HI_PLAYER_DecCallBack CallBack,
IN HI_VOID
*pPara);
封装如下:

/// <summary>
/// 初始化客户端的SDK,创建通道实例
/// </summary>
/// <param name="pHandle">通道的句柄</param>
/// <returns>通道的句柄</returns>
[DllImport("SESDK.dll")]
public static extern int OPESDK_Initialize(ref IntPtr pHandle);


/// <summary>
/// 注册解码数据输出回调
/// </summary>
/// <param name="pHandle">通道句柄</param>
/// <param name="callBack">解码后的数据输出回调</param>
/// <param name="pPara">用户参数</param>
/// <returns></returns>
[DllImport("SESDK.dll",CallingConvention=CallingConvention.Cdecl,CharSet=CharSet.Auto)]
public static extern int OPESDK_SetDecCallBack(IntPtr pHandle, HI_PLAYER_DecCallBack callBack, IntPtr pPara);

 

int state = JiaYIClient.OPESDK_Initialize(ref pHandle);
if (state != Const.SUCCESS) {
MessageBox.Show(
"初始化异常");
return;
}
eventCallBack
= new OnEventCallBack(eventCallback);
state
= JiaYIClient.OPESDK_SetEventCallBack(pHandle, u32Chn, eventCallBack, pData);


if (state != Const.SUCCESS )
{
MessageBox.Show(
"初始化异常");
return;
}
int state1 = 1;
state1
= JiaYIClient.OPESDK_SetUrl(pHandle, @"http://192.168.2.158:1026/0?trans=tcp&username=admin&password=123456");

if (state1 != Const.SUCCESS) {
MessageBox.Show(
"设置URL失败"+ state1);
return;
}

int state2 = 1;
state2
= JiaYIClient.OPESDK_SetWnd(pHandle, pWnd1);
if (state2 != Const.SUCCESS) {
MessageBox.Show(
"设置窗口失败");
return ;
}
int state3 = 1;
state3
= JiaYIClient.OPESDK_SetDecCallBack(pHandle, decCallBack, pData);
if (state3 != Const.SUCCESS)
{
MessageBox.Show(
"设置Dec失败");
return;
}

int state4 = 1;

state4
= JiaYIClient.OPESDK_Connect(pHandle);

if (Const.SUCCESS != state4) {
MessageBox.Show(
"连接失败");
return;
}

 

但是我发现 _stdcall 可以调用 而___declspec却不能够调用。请问大家能告诉我是什么原因吗?

wellen Liang的主页 wellen Liang | 初学一级 | 园豆:180
提问于:2011-01-15 14:56
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册