1、C#库要求:
.net framework 要与 调用者(c/c++项目) 版本保持一致。
2、C++项目属性设置:
3、引用C#库和调用C#代码:
#include "stdafx.h"
#include<string>
//引用库
#using "./CheckLicense.dll"
//引用c#命名空间
using namespace CheckLicense;
using namespace System;
int _tmain(int argc, _TCHAR* argv[])
{
String ^ c = gcnew String("");
//实例化对象
license ^check = gcnew license();
//调用对象方法
c=check->MarshalString();
//定义字符串
String ^ orgcode=gcnew String("");
String ^ datetime=gcnew String("");
//-9:机构代码错误 -12:过期
int result = check->IsTheLicenceRightAnalyze(c,datetime);
return 0;
}
4、注意:
当调用C#版 dll的项目生成的exe或dll 与被调用的C#版d