tags:

views:

15

answers:

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.

+1  A: 

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
This is what I've done, it's not immediately apparent that it forked to CSC until I watched it using ProcMon.
sixlettervariables