Note that there are some explanatory texts on larger screens.

plurals
  1. POProgrammatically generating typed DataSet for LINQ - "Metadata file" missing?
    primarykey
    data
    text
    <p>Title says what i'm trying to do. I can successfully generate an assembly if i don't specify the <code>LinqOverTypedDatasets</code> option, but i want my typed DataSet to support queries with LINQ.</p> <p>My code outputs the error:</p> <p><code>error CS0006: Metadata file 'System.Data.DataSetExtensions.dll' could not be found</code></p> <p>The code:</p> <pre><code>//System.Data.DataSet myDataSet = &lt;&lt; assume myDataSet is valid DataSet object &gt;&gt;; Dictionary&lt;string, string&gt; options = new Dictionary&lt;string, string&gt;(); 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); } </code></pre> <p><strong>EDIT: figured this out, corrected code appears above! :) The MSDN documentation is WRONG when it describes the setting the compiler version to 3.5. The value for CompilerVersion should be "v3.5" NOT "3.5" as the docs say.</strong></p> <p>I got the same compilation errors when i didn't reference required assembiles (System.dll, etc), which was fixed by adding them to the <code>ReferencedAssemblies</code> collection of the <code>CompilerParameters</code> object. However, when i received the error message about <code>System.Data.DataSetExtensions.dll</code>, adding that assembly to the <code>ReferencedAssemblies</code> still resulted in the same error.</p> <p>I noticed that <code>System.Data.DataSetExtensions.dll</code> isn't in the location i expected it to be (<code>\WINDOWS\Microsoft.NET\Framework\v3.5</code>), but in <code>\Program Files\Reference Assemblies\Microsoft\Framework\v3.5</code>. I tried specifying the full path, that didn't work either. I assumed that since the full path wasn't specified for the other referenced assemblies, it found them in the GAC. Is this not the case for <code>System.Data.DataSetExtensions.dll</code> ? Or is there something else going on?</p> <p>Thanks for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload