Programming to create a typed DataSet for LINQ - is there no metadata file?

The name says what I'm trying to do. I can successfully generate the assembly if I do not specify an option LinqOverTypedDatasets, but I want my typed DataSet to support queries using LINQ.

My code produces an error:

error CS0006: Metadata file 'System.Data.DataSetExtensions.dll' could not be found

The code:

//System.Data.DataSet myDataSet = << assume myDataSet is valid DataSet object >>;

Dictionary<string, string> options = new Dictionary<string, string>();
options.Add("CompilerVersion", "v3.5");

using (CSharpCodeProvider cscp = new CSharpCodeProvider(options))
{
    CodeNamespace ns = new CodeNamespace("DBSPPS");
    CodeCompileUnit ccu = new CodeCompileUnit();

    using (StringWriter schemaWriter = new StringWriter())
    {
        myDataSet.WriteXmlSchema(schemaWriter);
        TypedDataSetGenerator.Generate(schemaWriter.ToString(),
            ccu,
            ns,
            cscp,
            TypedDataSetGenerator.GenerateOption.LinqOverTypedDatasets
            );
    }

    StringWriter codeWriter = new StringWriter();

    cscp.GenerateCodeFromNamespace(ns, codeWriter, new CodeGeneratorOptions());

    CompilerParameters parameters = new CompilerParameters();
    parameters.GenerateExecutable = false;
    parameters.OutputAssembly = "DBSPPS.dll";
    parameters.ReferencedAssemblies.Add("System.dll");
    parameters.ReferencedAssemblies.Add("System.Data.dll");
    parameters.ReferencedAssemblies.Add("System.Xml.dll");
    parameters.ReferencedAssemblies.Add("System.Data.DataSetExtensions.dll");

    CompilerResults cr = cscp.CompileAssemblyFromSource(parameters,new string[]{ codeWriter.ToString() });

    foreach (string msg in cr.Output)
        Console.WriteLine(msg);
}

EDIT: it turned out, the corrected code appears above! :) MSDN WRONG documentation when it describes setting the compiler version to 3.5. The value for CompilerVersion should be "v3.5" NOT "3.5", as the docs say.

, (System.dll ..), ReferencedAssemblies CompilerParameters. , System.Data.DataSetExtensions.dll, , ReferencedAssemblies .

, System.Data.DataSetExtensions.dll , (\WINDOWS\Microsoft.NET\Framework\v3.5), \Program Files\Reference Assemblies\Microsoft\Framework\v3.5. , . , , , GAC. System.Data.DataSetExtensions.dll? - ?

.

+3
1

, 3.5 - . .

+1

All Articles