用于创建DLL的编程语言:C ++或C# [英] Programming Language for Creating DLL: C++ or C#

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

问题描述

这不是一个编程怀疑!

我要为某些应用程序编写一个DLL。
我有两个选择:C ++或C#在哪种语言中我应该写DLL?

I am going to write a DLL for some application. I have two options to choose from: C++ or C# In which language I should write DLL?

这是否会影响功能?

我是一个完全新手,不知道C ++和C#(但C#中的一些小程序)。

I am a completely newbie and Unaware of both C++ and C# (but Some Small programs in C#).

什么是优点和缺点在C ++或C#中编写DLL?

What are Pros and Cons about Writting DLL in C++ or C#?

非常感谢您的时间!

b Swanand!

Regards, Swanand!

推荐答案

DLL最好用C编写:

A DLL is best written in C :)

让我解释一下:

DLL的概念是在今天没有C ++的时候创建的。它是为C创建的。你可以用C ++编写DLL,但你只能从使用与DLL相同版本的相同编译器编写的应用程序轻松地使用它们。 AC DLL可以从.NET使用,不像C ++(是的,我知道,技术上它可以,但它是一个痛苦的臀部)。

The concept of DLL's was created when ther was no today's C++. It was created for C. You can write DLL's with C++ but you'll be able to easily use them only from applications that were written with the same version of the same compiler as the DLL. A C DLL can be used from .NET, unlike C++ (yeah, I know, technically it can, but it is a pain in the buttocks).

如果你创建DLL与C#(或任何其他.NET语言),它是一个完全不同的事情 - 它不是一个Windows DLL,它只是一个.Net程序集,没有一个入口点(Main),所以它可以从其他.NET程序集使用,通过引用DLL。

If you create DLL with C#(or any other .NET language), it's a completely other thing - it's not a windows DLL, it's just a .Net assembly without an entry point(Main), so it can be used from other .NET assemblies by referencing the DLL.

总结:


  1. 如果您需要使用DLL从.NET语言 - 写在C#,它不会是一个Windows DLL,只是一个程序集。非常容易使用。

  1. If you need to use your DLL from .NET languages - write it in C#, it won't be a windows dll, just an assembly. Very easy to use.

如果你需要使用你的DLL从ONLY C + +和ONLY从相同的编译器应用程序,不便携,易于使用。

If you need to use your DLL from ONLY C++ and ONLY from applications written by the same compiler, write in C++. Not portable, easy to use.

如果您想创建一个可以从.NET,C,C ++使用的通用库,编译器,使用标记为externC的C或C ++独立函数并具有类似指针和POD的C样参数。

If you want to create a general-purpose library that can be used from .NET, C, C++ and regardless of the compiler, use C, or C++ freestanding functions marked as extern "C" and having C-like parameters, like pointers and POD's.

HTH

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

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