Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

reference

csc

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?

like image 350
Deane Avatar asked May 19 '09 21:05

Deane


1 Answers

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.

like image 178
Luke Woodward Avatar answered Sep 29 '22 15:09

Luke Woodward