-1

I have a CodeDom setup that needs to reference some assemblies that are in the executable's directory. However, it appears that only the Working Directory and the GAC are searched for these assemblies, and not the executable directory.

var compilerOptions = new CompilerOptions {
    ReferencedAssemblies = {
        "System.dll",
        "System.Core.dll",
        "Assembly0.dll",
        "Assembly1.dll"
    }
};

The C# compiler will search:

  1. Application working directory
  2. GAC

For whatever reason it will not search for Assembly0.dll nor Assembly1.dll in the execution directory.

user7116
  • 63,008
  • 17
  • 141
  • 172
  • Will the c# compiler search the compilerOptions' referenced assemblies in the GAC? I think it is able to find System.dll because it lies in the same directory of csc.exe. If the compilerOption references any user installed assemblies in the GAC, I think the above setup will fail to compile. – Sridarshan Jun 11 '13 at 06:04

1 Answers1

2

The "execution directory" is only relevant to your process, not the csc.exe process. Just generate the full path for the assembly reference. Easy to do with System.Reflection.Assembly.GetEntryAssembly().Location

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • This is what I've done, it's not immediately apparent that it forked to CSC until I watched it using ProcMon. – user7116 Jul 19 '10 at 17:29