从本机C ++调用C#,而没有/ clr或COM? [英] Calling C# from native C++, without /clr or COM?

查看:126
本文介绍了从本机C ++调用C#,而没有/ clr或COM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题曾经被问过,但是我从来没有找到一个真正令人满意的解决方案-

This question has been asked before, but I never found a truly satisfying solution -

我有一个用C#编写的类库,我想从旧版本机C ++应用程序。主机应用程序是真正本机的,可以在Windows& Windows上编译。 Linux,它是一个控制台应用程序。因此,假设在Windows上使用Microsoft .NET,在Linux上使用Mono,那么如何使其称为C#类库。

I have a class library written in C#, and I want to call it from a legacy native C++ application. The host application is truly native, compiled on Windows & Linux, its a console application. So how can I make it call the C# class library, assuming using Microsoft .NET on Windows, and Mono on Linux.

我研究过SWIG和COM接口包装在Windows上,但是是否存在可以跨平台使用的标准公认解决方案?也就是说,这是通用的,可与Microsoft .NET和Mono一起使用,一次写入即可在任何地方实现。

I have looked at SWIG and wrapping with COM interfaces on Windows, but is there a standard recognized solution that works cross platform? i.e. that is generic, works with both Microsoft .NET and Mono, a write once use everywhere implementation.

解决方案应将完整的类接口从C#域公开到C ++

Solutions should expose the full class interfaces from the C# domain to the C++ domain.

类似的问题仅关注Windows解决方案,例如-

Similar questions focus only on the Windows solutions, for example -

在不使用COM的情况下从C ++调用C#方法

推荐答案

如果您要使用此跨平台,建议使用100%Mono方法。

If you want to do this cross platform, I would recommend going with a 100% Mono approach.

Mono具有干净的 Embedding API ,可在Linux和Windows上运行。

Mono has a clean Embedding API which works on Linux and Windows.

这篇关于从本机C ++调用C#,而没有/ clr或COM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆