I am compiling a DLL at runtime using CSharpCodeProvider. My code runs fine on some machines but on otherse it fails with the following error:
error CS0006: Metadata file 'EntityFramework.dll' could not be found
Here is a code snippet:
var csFile = ... // the file is in C:\Program Data\MyFolder\InnerFolder
using (var provider = new CSharpCodeProvider())
{
var parameters = new CompilerParameters
{
GenerateInMemory = false, // we want the dll saved to disk
GenerateExecutable = false,
CompilerOptions = "/target:library",
// the assembly is compiled to the same directory as the .cs file
OutputAssembly = GetNewCacheAssemblyPath(),
};
parameters.ReferencedAssemblies.AddRange(new[]
{
"System.dll",
"System.Data.dll",
"System.Data.Entity.dll",
"EntityFramework.dll",
});
var compilerResult = provider.CompileAssemblyFromFile(parameters, csFile);
}
Any thoughts as to why this might be happening?