7

I've copied a Dataset from one csproj to another, and the new project gets the following compile warning: "The custom tool 'MSDataSetGenerator' failed while processing the file 'Client.xsd'."

In researching this warning I discovered that if I opened a VS cmd prompt and run XSD.exe on the xsd file directly I get more info. It says: "Error: Can only generate one of classes or datasets."

The command line flag that fixes this is to run: XSD /d {xsdfilename}

If I run that on the cmd line it generates the dataset code just fine. But I can't figure out how to make Visual Studio do that. Anyone know?

live-love
  • 48,840
  • 22
  • 240
  • 204
dviljoen
  • 1,612
  • 1
  • 16
  • 28

4 Answers4

5

In my case, this error:

Error: Can only generate one of classes or datasets.

is because I forgot to add /c parameter to the xsd command:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\xsd.exe" /c myfile.cs
live-love
  • 48,840
  • 22
  • 240
  • 204
3

The trick I've found is to delete (or rename to a temp file just to be safe) the name of the Client.vb or Client.cs file associated with the DataSet. That way when you add the file to the project, it'll detect the appropriate XML related data and generate a new class for you.

Dillie-O
  • 29,277
  • 14
  • 101
  • 140
2

I'm running into the same problem, and have found a manual workaround for this.

  1. Open the properties for the XSD file in your project.
  2. Remove the MSDataSetGenerator entry from the Custom Tool property.
  3. Re-add the MSDataSetGenerator value for the Custom Tool property.

When you paste the MSDataSetGenerator value back in and hit enter, it will regenerate the file it needs.

I'll be sure to post back here when I figure out a better solution.

Dan R
  • 5,258
  • 2
  • 16
  • 10
0

If you right click on the XSD file in your project there is an option "Run Custom Tool". If the Custom Tool property of the XSD is set to MSDataSetGenerator this will regenerate the class.

Loathian
  • 1,177
  • 1
  • 14
  • 20