Search code examples
c#referencecsc

How do you use GAC'd assemblies as references with csc.exe?


I'm compiling from csc.exe (well, CruiseControl is...), and I need to reference a DLL in the GAC. I do not have the correct version of this DLL as a simple file, but there is a correct version in the GAC.

However, you can't reference assemblies in the GAC with csc -- you have to have the path to the actual file.

I've found some references that claim you can reverse engineer the path to the actual file, but I haven't been able to get them work. I fired up Fusion logging, and I can see where the runtime is getting the file from, but using a filepath to that location in my reference does not work.

So, how do you provide csc with a reference to an assembly version that only exists in the GAC?


Solution

  • I had a similar problem. The solution I used was to open a command prompt and change directory to something like the following (change it depending on which assembly you want):

    C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\
    

    You can then copy the DLL in this directory somewhere outside the GAC.