将 Assembly 安装到 GAC [英] Installing Assembly into GAC

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

问题描述

我尝试在 GAC 中使用安装程序集new System.EnterpriseServices.Internal.Publish().GACInstall("Foo.dll"); 但我找不到安装在 c:windowsassemblygac_msil 文件夹中.我也没有收到安全异常.谁能帮帮我

I tried to install an assembly in GAC using new System.EnterpriseServices.Internal.Publish().GACInstall("Foo.dll"); But I could not find that installed in c:windowsassemblygac_msil folder. I did not receive the securityexception as well. Can anyone help me

推荐答案

首先,确保它已签名.我认为这是因为你没有得到任何例外.此外,如果它是 .net 4.0 程序集,它将在新位置 @%windir%Microsoft.NETassembly

First of all, make sure it's signed. I assume it is since you didn't get any exceptions. Also, if it's a .net 4.0 assembly, it will be GACed at a new location @ %windir%Microsoft.NETassembly

更多相关信息:.NET 4.0 有一个新的 GAC,为什么?

更新:签名大会

右键单击程序集项目并转到属性".在项目属性"屏幕上选择签名"选项卡.选中签署程序集"并在选择强名称密钥文件"中选择新建".这将打开一个对话框,您必须在其中指定密钥名称.我通常使用解决方案名称作为我的密钥名称.您还可以密码保护密钥(您的偏好).完成后,在对话框中点击确定"并构建您的项目.现在再次尝试GAC.

Right click on the Assembly project and go to "Properties". On the "Project Properties" screen select "Signing" tab. Check "Sign the assembly" and in the "Choose strong name key file" select "new". That will open up a dialog where you have to specify the key name. I usually use solution name as my key name. You can also password protect the key (your preference). Once you're done, hit "OK" on the dialog and build your project. Now try to GAC it again.

快速建议:如果您希望 GAC 的项目中有多个程序集,您可以共享相同的密钥文件,而不是为每个程序生成一个新的.我通常将我的密钥文件放在我的解决方案文件所在的同一位置,并在解决方案中的项目之间共享它.

Quick suggestion: If you have multiple assemblies in the project you'd like to GAC, you could share the same key file instead of generating a new one for each. I usually drop my key file in the same location where my Solution file sits and share it across projects in the solution.

这篇关于将 Assembly 安装到 GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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