Имя типа или пространства имен linq отсутствует - C#
Формулировка задачи:
Делаю простенький билдер. Что делать дает ошибку "имя типа или пространства имен linq отсутствует"
Проект под который пилю билдер написан на 3.5
Фреймворк менять пробовал.
Params.ReferencedAssemblies.Add("System.Linq.dll");
Params.ReferencedAssemblies.Add("System.Core.dll");
тоже
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Management;
using System.Text;
using System.Windows.Forms;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Timers;
using System.Linq;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string filename;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
filename = openFileDialog1.FileName;
}
private void button2_Click(object sender, EventArgs e)
{
string filename;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
filename = openFileDialog1.FileName;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
try
{
CompilerParameters Params = new CompilerParameters();
Params.GenerateExecutable = true;
Params.ReferencedAssemblies.Add("System.dll");
Params.ReferencedAssemblies.Add("System.Windows.Forms.dll");
Params.ReferencedAssemblies.Add("System.Management.dll");
Params.ReferencedAssemblies.Add("System.Drawing.dll");
Params.ReferencedAssemblies.Add("System.Xml.dll");
Params.CompilerOptions += "\n/t:winexe"; //Убираем cmd окно путём объявления программы Windows приложением
Params.OutputAssembly = "file.exe"; //Имя исходного файла
string Source = Properties.Resources.bild; //Путь к файлу с исходниками
Source = Source.Replace("[DynamicMessage]", textBox1.Text);
Source = Source.Replace("[DynamicMessage1]", textBox2.Text);
var settings = new Dictionary<string, string>();
settings.Add("CompilerVersion", "v2.0");
CompilerResults Results = new CSharpCodeProvider(settings).CompileAssemblyFromSource(Params, Source);
if (Results.Errors.Count > 0)
{
foreach (CompilerError err in Results.Errors)
MessageBox.Show(err.ToString()); //Выводим циклом ошибки, если они есть
}
else
{
MessageBox.Show("Готово!"); //Выводим сообщение что всё прошло успешно
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
}
}Решение задачи: «Имя типа или пространства имен linq отсутствует»
textual
Листинг программы
Params.ReferencedAssemblies.Add("System.Core.dll");
settings.Add("CompilerVersion", "v3.5"); // Также можно v4.0