Question

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?

Was it helpful?

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.

OTHER TIPS

I'd recommend using Nant or MSBuild and just use the .csproj file generated by visual studio. Then simply get CruiseControl to use your Nant script. Below is an extract from a Nant script I wrote,

<csc target="library" output="${basedir}/bin/${basename}.dll" debug="${debug}" optimize="true">
  <sources>
    <include name="src/app/**/*.cs"/>
  </sources>
  <references refid="My.Assemblies" />
</csc>

and the references

      <assemblyfileset id="My.Assemblies"><include name="System.dll"></include>
    <include name="System.Configuration.dll"></include>
    <include name="System.Core.dll"></include>
    <include name="System.Data.dll"></include>
    <include name="System.Data.DataSetExtensions.dll"></include>
    <include name="System.Drawing.dll"></include>
    <include name="System.EnterpriseServices.dll"></include>
    <include name="System.Web.dll"></include>
    <include name="System.Web.Extensions.dll"></include>
    <include name="System.Web.Mobile.dll"></include>
    <include name="System.Web.Services.dll"></include>
    <include name="System.Xml.dll"></include>
    <include name="System.Linq.dll"></include>
</assemblyfileset>

When I compiled against the Excel PIA's, I used this path to specify a reference on the command line for csc.exe: C:\windows\assembly\GAC\Microsoft.Office.Interop.Excel\11.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

The compile succeeded.

?? Does this not work for you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top