是否可以同时制作同一 C++ 的托管版本和非托管版本? 集会?

发布于 2024-07-29 17:01:09 字数 173 浏览 1 评论 0原文

我们的一款产品使用另一家公司的软件。 该公司的一名开发人员有点“老”,并且使用 C 语言工作(无意冒犯)。 我们使用 .Net 3.5 (C#)。

他问我是否可以使用相同的源代码(可能是 C,也可能是 C++)创建一个可以编译托管版本和非托管版本的程序集。

这样做有什么充分的理由吗?

We use a software from another company for one of our products. A developer from that company is kinda 'old' and works in C (no offence). We work in .Net 3.5 (C#).

He asked me if it is possible, with the same source code (presumably in C, maybe C++), to create an assembly that he could compile both a managed and unmanaged version.

Are there any good reason to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡離愁欲言轉身 2024-08-05 17:01:09

为了编译为托管程序集,需要使用托管 C++ 扩展。 请注意,C 不是面向对象语言,因此您无法编译为托管程序集。

这样做的主要原因是,如果您有一个用 C++ 编写的现有代码库,并且希望直接在 .NET 应用程序中使用该代码库,而不需要借助 P/Invoke。

In order to compile to managed assembly the code needs to be written using Managed C++ Extensions. Please note that C is not an OO language so you cannot compile to a managed assembly.

The primary reason for doing this is if you have an existing code base written in C++ that you want to use directly in .NET application without resorting to P/Invoke.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文