简体   繁体   English

在Vista中将多个程序集注册到GAC

[英]Register Multiple Assemblies to the GAC in Vista

I've got a whole directory of dll's I need to register to the GAC. 我有一个完整的dll目录,我需要注册到GAC。 I'd like to avoid registering each file explicitly- but it appears that gacutil has no "register directory" option. 我想避免明确地注册每个文件 - 但似乎gacutil没有“register directory”选项。 Anyone have a fast/simple solution? 任何人都有快速/简单的解决方案?

GACUTIL doesn't register DLLs -- not in the "COM" sense. GACUTIL没有注册DLL - 不是“COM”意义上的。 Unlike in COM, GACUTIL copies the file to an opaque directory under %SYSTEMROOT%\\assembly and that's where they run from. 与COM不同,GACUTIL将文件复制到%SYSTEMROOT%\\ assembly下的不透明目录中,这就是它们运行的​​位置。 It wouldn't make sense to ask GACUTIL "register a folder" (not that you can do that with RegSvr32 either). 要求GACUTIL“注册一个文件夹”是没有意义的(不是你可以用RegSvr32做到这一点)。

You can use a batch FOR command such as: 您可以使用批处理FOR命令,例如:

FOR %a IN (C:\MyFolderWithAssemblies\*.dll) DO GACUTIL /i %a

If you place that in a batch file, you must replace %a with %%a 如果将其放在批处理文件中,则必须将%a替换为%% a

Here is the script you would put into a batch file to register all of the files in the current directory with Gacutil. 下面是您将放入批处理文件以使用Gacutil注册当前目录中的所有文件的脚本。 You don't need to put it in a batch file (you can just copy/paste it to a Command Prompt) to do it. 您不需要将其放在批处理文件中(您可以将其复制/粘贴到命令提示符)来执行此操作。

FOR %1 IN (*) DO Gacutil /i %1

Edit: Bah, sorry I was late. 编辑:呸,对不起,我迟到了。 I didn't see the previous post when I posted mine. 当我发布我的帖子时,我没有看到上一篇文章。

Use 使用

gacutil /il YourPathTo_A_TextFile.txt gacutil / il YourPathTo_A_TextFile.txt

switch, if you have dlls in multiple different folders. 切换,如果你有多个不同的文件夹中的dll。 Otherwise go with the for ... in loop mentioned by Euro. 否则请使用欧元提到的for ... in循环。

The text file should contain a list of assembly paths (one path per line) which should be installed. 文本文件应包含应安装的程序集路径列表(每行一个路径)。 The paths can also be different folders all over the system. 路径也可以是整个系统的不同文件夹。 Run the command line as an administrator! 以管理员身份运行命令行!

Here an example of the YourPathTo_A_TextFile.txt: 这是YourPathTo_A_TextFile.txt的一个示例:

C:\\...Microsoft.Practices.EnterpriseLibrary.Common.dll C:\\...Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapter.dll C:\\...Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapterV5.dll C:\\...Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime.dll C:\\...Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.dll C:\\...Microsoft.Practices.EnterpriseLibrary.Data.dll C:\\ ... Microsoft.Practices.EnterpriseLibrary.Common.dll C:\\ ... Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapter.dll C:\\ ... Microsoft.Practices.EnterpriseLibrary.Configuration.Design。 HostAdapterV5.dll C:\\ ... Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime.dll C:\\ ... Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.dll C:\\ ... Microsoft.Practices.EnterpriseLibrary.Data .DLL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM