C++调用C# DLL

配置C++项目MathCon的属性配置:添加公共语言运行支持,如下图

C++调用C# DLL_第1张图片


具体调用方法如下:

#include 
#using 
#include "stdafx.h"
#include 
#include 
#include 

using namespace System;
using namespace System::Runtime::InteropServices;

#using "F:\\ClassLibrary1\\Debug\\ADSTestLibrary.dll"
using namespace std;
using namespace ADSTestLibrary;


int _tmain(int argc, _TCHAR* argv[])
{

	ADSTestLibrary::ITimsLibrary ^lib = gcnew TimsLibrary();
	String ^tres = "";
	int flag = 0;
	lib->ITIMS_CHECK_STATION("1234567890", "SN", tres, flag);

	printf("%s\n", tres);
	system("pause");


	return 0;
}

你可能感兴趣的:(C#)