Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I deploy dlls to a system's GAC and check for their existence on program startup?

Entity Framework references some DLLs. On one system, they showed up in the GAC which is very convenient. I can't figure out how I did this. The installer doesn't seem to do this --

The dlls I'm specifically talking about here are:

  • The core library assembly Microsoft.Practices.EnterpriseLibrary.Common.dll
  • The Unity Application Block assembly Microsoft.Practices.Unity.dll
  • The Object Builder assembly Microsoft.Practices.ObjectBuilder2.dll

but I guess it applies to any dll one might want to add to the GAC. Also is there a way to check on program startup whether an assembly even is in the GAC?

like image 810
Matt Avatar asked Jul 07 '10 18:07

Matt


1 Answers

Check if is in the GAC:

bool inGac = System.Reflection.Assembly.Load(assemblyName).GlobalAssemblyGac;

To install in gac, there's a question Methods to programmatically install a .NET assembly into the GAC

like image 50
onof Avatar answered Nov 02 '22 15:11

onof