本文介绍了方法:以编程方式安装.NET程序集到GAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个小的应用程序或脚本,以.NET程序集安装到GAC。我读过有几个方法可以做到这一点,包括:

I need to create a small app or script to install a .NET assembly into the GAC. I've read there are a couple ways to do this including:

  • 使用的Gacutil.exe
  • 执行的code以下行:

  • using gacutil.exe
  • executing the following line of code:

新System.EnterpriseServices.Internal.Publish()GACInstall(Foo.dll);

不过,如果我刚刚创建的机器上相应的目录和装配复制到该目录中会发生什么?海关总署目录的结构如下: C:\ WINDOWS \组装\ GAC_MSIL \富\<版本#> __<公共令牌GT; \ Foo.dll

However, what would happen if I just created the appropriate directories on the machine and copied the assembly into that directory? The structure of the GAC directory is the following: C:\Windows\assembly\GAC_MSIL\Foo\<version#>__<public token>\Foo.dll

执行上面的两种方法做什么特别的,除了在创建文件夹结构,并把组装成吗?

Do the above two methods do anything special besides creating the folder structure and placing the assembly into it?

推荐答案

我的强烈的建议用现有的方法(比如你提到的那些),因为它们都支持和微软保持着并将继续未来版本的工作。

I strongly recommend using existing methods (like the ones you mentioned) because they are both supported and maintained by Microsoft and will continue to work with future releases.

有一个快速浏览一下的Gacutil.exe 进程监视器显示,有更多的一点点不只是复制文件:

A quick look at gacutil.exe with Process Monitor reveals that there is a little bit more to it than just copying files:

  • 在并发性的担忧(如临时文件,锁定 WINDOWS \组装\ GACLock.dat 等)
  • 的通知(如 HKLM \ SOFTWARE \微软\融合\ GACChangeNotification \ ...
  • 在索引(如 HKLM \ SOFTWARE \微软\融合\ NativeImagesIndex ...
  • 验证(如强名称,...)
  • concurrency concerns (e.g. temporary files, locking WINDOWS\assembly\GACLock.dat, etc.)
  • notifications (e.g. HKLM\SOFTWARE\Microsoft\Fusion\GACChangeNotification\...)
  • indexing (e.g. HKLM\SOFTWARE\Microsoft\Fusion\NativeImagesIndex...)
  • validation (e.g. strong name, ...)

在包装的System.EnterpriseServices 非常相似这个老博客文章并应该工作得很好。

The wrapper in System.EnterpriseServices is very similar to this old blog post and should work just fine.

这篇关于方法:以编程方式安装.NET程序集到GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 12:38