Search code examples
asp.netxsdstrongly-typed-datasetvs-web-application-project

Typed DataSets in WebApplication Projects


I am converting an older C# Website Project into a Web Application Project so that we can better manage it in our source control system. I have run into a problem.

The Website Project used strongly-typed-datasets (i.e. .XSD files). There is C# code written that uses these strongly typed datasets as an object. That worked fine when it was a Website Project but does NOT compile now that it is a Web Application project. The compiler can not find the reference to the datas set because datasets are not compiled.

Is there an easy solution to this problem?


Solution

  • You could use XSD.exe on the command line to generate the dataset classes into a class file and add the file to the new project.

    xsd.exe StronglyTypedDataset.xsd /dataset
    

    This will generate the file "StronglyTypedDataset.cs". Use the /namespace:My.Project.Namespace flag if you need to put the dataset classes into a specific namespace.

    This is essentially what's going on behind the scenes in your website project.