C语言的动态库在C#中如何声明及调用
C的函数声明:
int __declspec(dllexport) __cdecl des_encrypt(unsigned char * des_key, unsigned char * des_data, int des_len, unsigned char * des_result);
用WIN8下VS2010开发WinForm程序,项目目标平台为x86,动态库声明如下:
[DllImport("des.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
public static extern int des_encrypt(ref string des_key, ref string des_data, int des_len, ref string des_result);
调用:
string key = "12345678";
string mingw = textBox1.Text;
string miw = "";
int i = BankPayPublic.des_encrypt(ref key, ref mingw, mingw.Length, ref miw);
前几次运行时报“System.ExecutionEngineException”的异常,调试几次后现在每次都是“vshost32-clr2.exe停止工作”,急求解决方案,多谢!
int __declspec(dllexport) __cdecl des_encrypt(unsigned char * des_key, unsigned char * des_data, int des_len, unsigned char * des_result);
用WIN8下VS2010开发WinForm程序,项目目标平台为x86,动态库声明如下:
[DllImport("des.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
public static extern int des_encrypt(ref string des_key, ref string des_data, int des_len, ref string des_result);
调用:
string key = "12345678";
string mingw = textBox1.Text;
string miw = "";
int i = BankPayPublic.des_encrypt(ref key, ref mingw, mingw.Length, ref miw);
前几次运行时报“System.ExecutionEngineException”的异常,调试几次后现在每次都是“vshost32-clr2.exe停止工作”,急求解决方案,多谢!
...全文
相关推荐
Demo: c/c++动态库(DLL)调用,c#等其他语言调用c/c++的DLL
**C++动态库调用C动态库**:由于C语言的ABI(应用程序二进制接口)兼容性,C++代码可以直接调用C语言编写的DLL。
dll 动态库编程 | C++名称改编、标准C接口、extern “C”、函数调用约定以及def文件详解
dll 动态库编程 | C++名称改编、标准C接口、extern “C”、函数调用约定以及def文件详解
C# 调用 C++ 动态库并调用自身注册到动态库的函数
例如,C++动态库中有如下函数声明:```cppextern "C" __declspec(dllexport) void CallBack(void (*callback)(int));```在C#中
C#与VC互相调动态库_方案及源码
C# DLL中的类实现,导出公共方法供C++调用。3. C++ DLL的头文件,声明C语言风格的函数,用`extern "C"`修饰。4. C++ DLL的实现文件,包含函数的具体实现。5.
C#程序调用VC++程序动态库
在Windows操作系统中,VC++编译器创建的DLL文件能够被C#等其他编程语言调用,实现了不同语言间的交互。要实现C#调用VC++动态库,我们需要遵循以下步骤:1.


