应该被赋予“模块名称"的名称.当我用强名称链接程序集时 [英] what should be given as "Module Name" when I am linking an assembly with the strong name

查看:63
本文介绍了应该被赋予“模块名称"的名称.当我用强名称链接程序集时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试创建一个强名称并将该dll添加到GAC.
我已经为该dll创建了强名.
但是,当我使用AL命令将该强名称链接到dll时,
我被卡住了.
它具有如下语法,

al/out:[程序集名称] [模块名称]/Keyfile:[文件名称]

但是这里的模块名称是什么.我们应该在这里给出什么?
你能帮我吗?

谢谢,
Srikrishna

Hi ,


I am trying to create a strong name and add that dll to the GAC.
I have created the strong name for that dll.
But,when I am linking that strong name to the dll using AL command,
I am stuck.
It has the syntax as below,

al /out:[assembly name] [module name] /Keyfile:[file name]

But what is module name here.what we should give here?
Can you please help me.

Thanks,
Srikrishna

推荐答案

好,首先al.exe本身不适用于GAC.它只是创建一个装配.相对于GAC的唯一参数是Keyfile,因为需要强命名.

组装有两个包装级别.通常,程序集是在单个可执行文件(通常为.DLL.EXE,但可以是其他任何文件)中编译的.可执行文件本身不代表程序集,而是代表模块.我在这里讨论的最简单的情况是:在单个模块中进行单个组装.

对于MS Visual Studio,情况总是如此.创建的所有程序集都是单模块程序.

在这种情况下,请不要在AL中使用module参数-完全不要.

更高级的情况是,当您首先创建一些可执行模块(通过al.execsc.exe等)时,模块只是代码包,与程序集无关.在此步骤中,模块是 output 文件的参数.下一步,使用相同或另一个编译器来创建程序集本身,并将模块用作输入参数.此步骤将创建另一个称为启动模块的模块(对于.EXE,它应该包含main,对于所有程序集,它都应带有程序集清单).在此步骤上创建的可执行文件包含清单和所有元数据,它们显示.NET加载了要链接到正在创建的程序集的其他模块(在先前步骤中创建的那些模块).

为什么要完全使用模块?嗯,单模块模型之间的差异不是很大.模块不包含程序集属性,例如版本或安全属性(重要).

如果不同的程序集需要重新使用一些可执行代码怎么办?如果不同的程序集使用相同的版本,安全性等,则可能没有意义-使此重复使用的代码成为另一个程序集.但是,如果您想在代表完全不同的系统的程序集中重复使用此代码,该程序几乎是独立开发的,具有不同的版本,那么,就知道了.
在这种情况下,请将重用的代码放在单独的模块中.模块与程序集无关,它们将容忍此类滥用.

最后,如果使用Visual Studio来使GAC接受程序集,您是否真的需要使用al.exe(或csc.exe)?不,如果您没有VS(将源代码部署给没有VS的用户的方式),那么裸露的编译器非常有用,但是如果您只想使用VS,请执行以下操作:转到项目属性,在签名"项下的页面-> 签署大会"-> 选择一个强名称键"->浏览->然后使用您已经创建的签名文件.

至于编译器中的module参数,您已经明白了:这是您选择的任何文件名(生成module时),只有当它是输入参数(步骤2)时,它才应该是现有文件.
Ok, first al.exe does not work with GAC per se. It just creates an assembly. The only parameter relative to GAC is Keyfile, as strong naming is required.

There are two level of packaging of the assembly. Usually, assembly is compiled in a single executable file (usually .DLL or .EXE, but can be anything else). The executable file itself does not represent assembly, it represent module. The most simple case I discuss here is: single assembly in a single module.

With MS Visual Studio, this is always the case. All assemblies created are single-module ones.

In this case, do not use module parameter in AL -- not at all.

More advanced case is when you create some executable modules first (by al.exe, csc.exe, etc.) Modules are just packages of code, they are assembly-agnostic. On this step, the module is a parameter for output file. On next step, you use the same or another compiler to create assembly itself, using the module(s) as input parameter. This step creates one more module called start-up module (for .EXE, it should contain main, for all assemblies, it should carry assembly manifest). The executable file created on this step contains manifest and all meta-data showing the .NET loaded what other modules to link to the assembly being created (those created on previous step(s)).

Why using modules at all? Well, the difference between single-module model is not so big. A module carries no assembly attributes such as version or security attributes (important).

What if you need to re-use some executable code if different assemblies? If the different assemblies use identical version, security, etc., it may make no sense -- make this re-used code another assembly. But what if you want to re-use this code in assemblies representing very different systems, developed almost independently, with different versions,.. well, you got it.
In this case, put the re-used code in a separate module(s). Modules are agnostic to assemblies, they will tolerate such abuse.

Finally, do you really need to use al.exe (or csc.exe) if you use Visual Studio to make assemblies accepted by GAC? No, the naked compilers are great if you do not have VS (the way to deploy source code to the users not having VS), but if you want to use just VS: go to project properties, the page under the item "Signing" -> "Sign the Assembly" -> "Choose a strong name key" -> Browse -> then use your already created signature file.

As to the module parameters in compilers, you got it: this is any file name for your choice (when you generate a module), only if it is an input parameter (step 2), it should be existing file.


这篇关于应该被赋予“模块名称"的名称.当我用强名称链接程序集时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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