编写C#和C ++应用程序的DLL [英] Writing DLL for C# and C++ Applications

查看:116
本文介绍了编写C#和C ++应用程序的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写几个DLL,这两个都可以从C#应用程序和C ++应用程序访问。最初,我想我可以通过编写C#中的DLL并从C#和C ++应用程序链接到它们来节省时间/精力。这个方法是明智的,还是应该使用C ++编写DLL?

I need to write a couple DLLs that will both be accessed from a C# application and a C++ application. Initially, I was thinking that I could save time/effort by writing the DLLs in C# and linking to them from the C# and C++ applications. Is this approach wise, or should the DLLs be written using C++?

推荐答案

我的建议是实现代码,最舒适,但不要忘记interop要求,当你去。了解您的接口是什么,以及在最终产品中需要什么胶。在填写实现之前编写接口并测试interop。

My advice would be to implement the code where you are most comfortable, but don't forget the interop requirement as you go. Know upfront what your interface is and what glue is required in the end product. Write the interface and test the interop before you fill out the implementation.

如果你的要求的复杂性使舒适度无关紧要,我会写在C ++中,你可以通过P / Invoke访问。

If the complexity of your requirement makes comfort level irrelevant, I would write it in C++ in such a way that you can access via P/Invoke.

一个重要的因素是你使用C ++ / CLI或本地C ++。这在C ++ / CLI和C#之间互操作要容易得多,在任何方向。

One important factor is are you using C++/CLI or native C++. It's a lot easier to interop between C++/CLI and C#, in either direction.

这篇关于编写C#和C ++应用程序的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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