将程序集安装到 GAC 中

发布于 2024-10-29 22:22:06 字数 178 浏览 10 评论 0原文

我尝试使用以下命令在 GAC 中安装程序集 new System.EnterpriseServices.Internal.Publish().GACInstall("Foo.dll"); 但我找不到安装在 c:\windows\ assembly\gac_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:\windows\assembly\gac_msil folder. I did not receive the securityexception as well. Can anyone help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鯉魚旗 2024-11-05 22:22:06

首先,确保它已签名。我认为这是因为你没有遇到任何例外。
另外,如果它是 .net 4.0 程序集,它将在新位置 @ %windir%\Microsoft.NET\ assembly\ 进行 GACed。

更多信息请参见:.NET 4.0 有一个新的 GAC,为什么?

更新:签名程序集

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

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

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.NET\assembly\

More on this here: .NET 4.0 has a new GAC, why?

UPDATE: Signing Assembly

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文