I'm trying to use CSharpCodeProvider to compile a piece of code.
The error is:
c:\...\crust.cs(551,48) : error CS1061: 'string' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
The code being compiled is:
using System;
...
using System.Linq;
...
return new string(str.Substring(1).Select(character => (char)((character - 54545) ^ key)).ToArray());
...
The code compiling the source is as follows:
...
String exeName = String.Format("NAME.exe");
CompilerParameters cp = new CompilerParameters
{
GenerateExecutable = true,
GenerateInMemory = false,
OutputAssembly = "NAME.exe",
CompilerOptions = "/target:exe /platform:x64"
};
cp.ReferencedAssemblies.Add("System.dll");
...
cp.ReferencedAssemblies.Add("System.Linq.dll");
cp.GenerateExecutable = true;
cp.OutputAssembly = exeName;
cp.GenerateInMemory = false;
cp.TreatWarningsAsErrors = false;
CompilerResults cr = provider.CompileAssemblyFromFile(cp,
sourceName);
...
No other system.linq methods work either.
Notes: Compiler is 64 bit Source is being compiled in to 64 bit Compiler is in .net framework 4.0 Source is being compiled in to .net 4.0