在.NET中,是否有必要注册DLL? [英] In .NET, is there a need to register the DLL?

查看:132
本文介绍了在.NET中,是否有必要注册DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否需要注册一个编译的DLL在目标机器上(用C#.NET)。

Is it necessary to register a compiled DLL (written in C# .NET) on a target machine.

目标机器将安装.NET,它是不够的,只是下降的DLL到目标机器?

The target machine will have .NET installed, is it enough to simply drop the DLL onto the target machine?

推荐答案

我想你混淆的东西一点点。登记一个d​​ll从未需要的,以便使用它。

I think you're confusing things a little. Registering a dll has never been needed in order to use it.

使用DLL只需要加载它(给定一个已知位置,或者如果库系统路径),并得到函数的地址,你想用。

Using a dll requires only to load it (given a known location or if the library is in the system path) and get the address of the function you wanted to use.

分发COM或者需要某些条目添加到Windows注册表中的ActiveX对象时注册DLL使用。为了使用COM服务(例如),您需要引用一个GUID—即,一个唯一的标识符—它可以让你获得一个句柄来实现该服务的DLL(或提供访问它)。有时候,你可以参考一个完全合格的名称,得到相同的结果。

Registering the dll was used when distributing COM or ActiveX objects which need to add certain entries to the windows registry. In order to use a COM service (for example) you need to reference a GUID — that is, a unique identifier — which allows you to get a handle to the dll that implements the service (or provide access to it). Sometimes you can make reference to a fully-qualified name and get the same results.

为了让所有的工作需要进行注册的DLL。这种注册的过程只是在注册表中创建几个条目,但主要是这两个:一个DLL的位置关联的GUID(这样就可以通过GUID引用它不知道它在哪儿确切位置),第二个相关联的全名的GUID。但同样,这仅仅是为COM或ActiveX对象。

In order for all that to work the dll needed to be registered. This "registration" process just creates several entries in the registry, but mainly these two: one associating a GUID with the location of the dll (so that you can reference it through the GUID without knowing where is it exactly located) and a second one associating the full name with the GUID. But again, this is just for COM or ActiveX objects.

在开发.NET应用程序,在需要的时候没有你不必担心找不到或加载它们在你的项目中引用的库会自动加载。为了给,该框架检查两个位置的引用的库

When you develop an application in .NET, the libraries referenced on your project are automatically loaded when they're needed without you having to worry about locating or loading them. In order to to that, the framework checks two locations for the referenced libraries.

  • 在第一个位置是应用程序的路径。
  • 第二个位置是GAC。

GAC(全局程序集缓存),可以有效地注册DLL在整个系统中使用,并可以作为旧登记机构的发展。

The GAC (Global Assembly Cache) allows you to effectively register a dll to be used throughout the system and works as an evolution of the old registering mechanism.

所以基本上你只需要把DLL在应用程序的同一个文件夹。

So basically you just need to put the dll in the same folder of the application.

这篇关于在.NET中,是否有必要注册DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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