与.net API的接口 [英] Interfacing to a .net API
本文介绍了与.net API的接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序是使用MFC用C ++编写的.如何与仅支持C#的.NET API接口?
解决方案
解决方案之一:指定项目属性中的公共语言运行时支持(/clr)"选项.然后,您可以添加对使用C#编写的程序集(甚至系统程序集)的引用.
然后可以使用 gcnew 创建C#对象,并使用特定的C ++/CLI规则直接调用C#函数(例如 字符串^" 与需要C#"字符串" 对象的函数进行交互).
My application is written in C++ using MFC. How can I interface to a .NET API that only supports C#?
解决方案
One of the solutions: specify the "Common Language Runtime Support (/clr)" option in Project Properties. Then you can add a reference to the assembly made in C# (and even to system assemblies).
Then it is possible to create C# objects with gcnew and call the C# functions directly, using specific C++/CLI rules (e.g. ‘String^’ to interact with a function that expects a C# ‘string’ object).
这篇关于与.net API的接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文