如何在C ++项目中使用C#代码 [英] How to use C# code in C++ project
问题描述
我在C#中有一些代码,我想在其他项目中使用(在C ++中编码)。
从我研究的,我需要创建一个.lib,但MSVS只创建.dll(我认为..)。我想有可能使用LoadLibrary()通过使用C ++,但似乎不是很友好。
I have some code in C# which I want to use in other project (coded in C++). From what I researched, I need to create a .lib but MSVS only creates .dll (I think..). I think is possible to use the .dll by using LoadLibrary() over C++ but seems not very friendly.
1 - 我可以在MSVS中创建。如果没有,我该如何创建它。
1 - Can I create the .lib in MSVS? If not, how can I create it.
2 - 集成代码的最好方法是什么? .lib或使用.dll + LoadLibrary()?
2 - What is the best way to integrate the code? By the .lib or using .dll + LoadLibrary()?
推荐答案
最简单的方法是使用C ++ / CLI 。这允许您使用两个对象系统(.NET和传统C ++及其标准模板库)。
The easiest option, honestly, is to use C++/CLI. That lets you use both object systems (.NET, and traditional C++ with its standard template library).
这篇关于如何在C ++项目中使用C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!