Reference Assembly in the GAC


Sponsored Links

73058_New Scooba® 230 Floor Washing Robot + Free Shipping!

 

Reference Assembly in the GAC

Here we look at how to reference an assembly (.dll file) in the GAC.

I've been quite surprised lately when I've been trying to add references in Visual Studio to assemblies in the Global Assembly Cache (GAC). I was quite confident I knew what to do, you would be to do it from inside Visual Studio and you would point the reference to the GAC, and perhaps select Copy Local and then your project would always reference the assembly, even when deploying to a different server. But how wrong I was, perhaps this was something you could in earlier versions of Visual Studio, but never mind, we have to get it working some other way.

Reference Assembly in the GAC - Quick Fix

Well there is a really quick fix, albeit not quite ideal, but one quick way you can do this is:


1. Manually copy the assembly yourself into the bin folder of your application
2. Include the assembly and bin folder in the project if they're not already showing by now
3. Add a reference to the assembly sitting inside your bin folder.


Hey presto, now your project has it's own copy of the assembly, so when the project is deployed to any server, the assembly will always be available, even if it's not in the GAC.