Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Assembly into GAC

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

like image 846
Muthukumar Palaniappan Avatar asked Apr 02 '11 03:04

Muthukumar Palaniappan


Video Answer


1 Answers

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.

like image 177
Sergey Akopov Avatar answered Sep 26 '22 01:09

Sergey Akopov