GAC Files from C# Code

I am trying to add new DLLs to the GAC (Global Assembly Cache) from C# code. Is this even possible? what is the best way to do it?

We are using a clickonce installer to update an application. I want to be able to GAC from the code any new DLLs that are new in the solution.

These files need to be in the GAC, as a requirement.

Upvotes: 1

Views: 561

Answers (1)

Lars Truijens
Lars Truijens

Reputation: 43602

You can do it from C# using the GAC/Fusion API documented here and here. An example in C# can be found here (thanks to Hans Passant), here or here. A simpler alternative are the GacInstall and GacRemove methods of the System.EnterpriseServices.Internal.Publish class, but they lack features and proper error reporting.

Upvotes: 1

Related Questions