none
Typed DataTable Designer (xsd) error: "Column requires valid DataType" - why? RRS feed

  • Question

  • I have created a typed dataset. The data is not bound to a database. I'm currently just using it as some other way of a typed collection (kind of a DataTable based generic collection).

    One of the columns in one of the typed DataTable definitions refers to a public class defined in some other project of the solution.

    So far, so good...

    Now I have moved an enumeration to a dedicated namespace; and from this moment on, when I try to open the designer, I get an error message, telling me that a "column requires valid DataType".

    I have already amended all references to the enumeration in the .Designer.cs file, but still this error occurs...

    Here's the stack trace I get from the error message screen:

    bei System.Data.DataColumn.set_DataType(Type value)
    bei System.Data.XSDSchema.SetProperties(Object instance, XmlAttribute[] attrs)
    bei System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement elem, DataTable table, Boolean isBase)
    bei System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)
    bei System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)
    bei System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)
    bei System.Data.XSDSchema.HandleTable(XmlSchemaElement node)
    bei System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)
    bei System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
    bei System.Data.DataSet.ReadXSDSchema(XmlReader reader, Boolean denyResolving)
    bei System.Data.DataSet.ReadXmlSchema(XmlReader reader, Boolean denyResolving)
    bei Microsoft.VSDesigner.DataSource.DesignDataSource.ReadXmlSchema(DataSourceXmlTextReader xmlReader)
    bei Microsoft.VSDesigner.DataSource.DesignDataSource.ReadXmlSchema(TextReader textReader, String baseURI)
    bei Microsoft.VSDesigner.DataSource.Designer.DataSourceSerializationService.DeserializeToDataSource(String filePath, Object serializationData)
    bei Microsoft.VSDesigner.DataSource.ProjectDataSourceDescriptor.LoadDataSource()
    bei Microsoft.VSDesigner.DataSource.ProjectDataSourceDescriptor.Init(IServiceProvider provider, IVsHierarchy primaryHierarchy, UInt32 primaryItemId, Object primaryDocDataObject, UInt32 docCookie, IVsInvisibleEditor invisibleEditor, IDesignerHost host)
    bei Microsoft.VSDesigner.DataSource.ProjectDataSourceStorage.EnsureInvisibleEditor(ProjectItem dsProjectItem, Boolean ensureWritable, Boolean createInvisibleEditor, Boolean getUIInfo)
    bei Microsoft.VSDesigner.DataSource.ProjectDataSourceStorage.GetDataSourceInternal(Object caller, ProjectItem dsProjectItem, Boolean ensureWritable, Boolean createInvisibleEditor, Boolean getUIInfo)
    bei Microsoft.VSDesigner.DataSource.Designer.DataSourceDesignerLoader.HandleLoad(IDesignerSerializationManager serializationManager)

     

    What's the problem here? How can I get this back to work?

    Your help is appreciated!

     


    Vote here for a Microsoft Connect feedback channel on Windows - and win a better Windows!

    Tuesday, May 31, 2011 1:14 PM

Answers

  • Well, you've definitely got a lot of extra useless stuff in your .xsd. Unfortunately, the DataDesigner adds all that in there and since you're not even using it for database access, I'd re-work it a bit (I'd re-work it even if you *were* using it for database access because I don't believe in using those darn TableAdapters).

    Anyway, see my blog posts for a way of creating a cleaner .xsd without all that extra database TableAdapter stuff in there (which, IMHO, does not belong there ... Visual Studio introduced that in VS2005, VS2003 did NOT have it and the .xsd's were *much* cleaner).

    http://geek-goddess-bonnie.blogspot.com/2010/04/create-xsd.html

    In that blog post, there's also a link to an earlier post I wrote against TableAdapters. You might want to read that one too because I talk about why your DataSet should know nothing about where it gets its data from.

    Let me know if that helps!


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Wednesday, June 1, 2011 3:17 PM

All replies

  • What does your .xsd look like? Is it using this enum? It sounds like you have a namespace problem, given that the symptoms started after you moved the enum to a different namespace. I think you have to also reference a new namespace in the .xsd itself (I don't usually put custom data types in a Typed DataSet, so I can't say that with 100% certainty). At any rate, post a bit of your .xsd and maybe something will jump out.
    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Wednesday, June 1, 2011 4:42 AM
  • Hi Bonnie,

    thanks for trying to help!

    I hope the following xsd file is of any help for you?

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="TypedDataTables" targetNamespace="http://tempuri.org/TypedDataTables.xsd" xmlns:mstns="http://tempuri.org/TypedDataTables.xsd" xmlns="http://tempuri.org/TypedDataTables.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
        <xs:annotation>
            <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
                <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
                    <Connections />
                    <Tables />
                    <Sources />
                </DataSource>
            </xs:appinfo>
        </xs:annotation>
        <xs:element name="TypedDataTables" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="true" msprop:Generator_DataSetName="TypedDataTables" msprop:Generator_UserDSName="TypedDataTables">
            <xs:complexType>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="ResultTable" msprop:Generator_TableClassName="ResultTableDataTable" msprop:Generator_TableVarName="tableResultTable" msprop:Generator_TablePropName="ResultTable" msprop:Generator_RowDeletingName="ResultTableRowDeleting" msprop:Generator_UserTableName="ResultTable" msprop:Generator_RowChangingName="ResultTableRowChanging" msprop:Generator_RowEvHandlerName="ResultTableRowChangeEventHandler" msprop:Generator_RowDeletedName="ResultTableRowDeleted" msprop:Generator_RowEvArgName="ResultTableRowChangeEvent" msprop:Generator_RowChangedName="ResultTableRowChanged" msprop:Generator_RowClassName="ResultTableRow">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="ProcedureName" msdata:Caption="Prozedur" msprop:Generator_ColumnVarNameInTable="columnProcedureName" msprop:Generator_ColumnPropNameInRow="ProcedureName" msprop:Generator_ColumnPropNameInTable="ProcedureNameColumn" msprop:Generator_UserColumnName="ProcedureName" type="xs:string" />
                                <xs:element name="FilterName" msprop:Generator_ColumnVarNameInTable="columnFilterName" msprop:Generator_ColumnPropNameInRow="FilterName" msprop:Generator_ColumnPropNameInTable="FilterNameColumn" msprop:Generator_UserColumnName="FilterName" type="xs:string" />
                                <xs:element name="SearchFunctionName" msdata:Caption="Funktion" msprop:Generator_ColumnVarNameInTable="columnSearchFunctionName" msprop:Generator_ColumnPropNameInRow="SearchFunctionName" msprop:Generator_ColumnPropNameInTable="SearchFunctionNameColumn" msprop:Generator_UserColumnName="SearchFunctionName" type="xs:string" />
                                <xs:element name="Result" msdata:DataType="ProcParserFilters.Result.SqlResult, ProcParserFilters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" msdata:Caption="Resultat" msprop:Generator_ColumnVarNameInTable="columnResult" msprop:Generator_ColumnPropNameInRow="Result" msprop:Generator_ColumnPropNameInTable="ResultColumn" msprop:Generator_UserColumnName="Result" type="xs:anyType" />
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="SqlProgramDescriptor" msprop:Generator_TableClassName="SqlProgramDescriptorDataTable" msprop:Generator_TableVarName="tableSqlProgramDescriptor" msprop:Generator_TablePropName="SqlProgramDescriptor" msprop:Generator_RowDeletingName="SqlProgramDescriptorRowDeleting" msprop:Generator_UserTableName="SqlProgramDescriptor" msprop:Generator_RowChangingName="SqlProgramDescriptorRowChanging" msprop:Generator_RowEvHandlerName="SqlProgramDescriptorRowChangeEventHandler" msprop:Generator_RowDeletedName="SqlProgramDescriptorRowDeleted" msprop:Generator_RowEvArgName="SqlProgramDescriptorRowChangeEvent" msprop:Generator_RowChangedName="SqlProgramDescriptorRowChanged" msprop:Generator_RowClassName="SqlProgramDescriptorRow">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="ProgramName" msdata:Caption="Programmname" msprop:Generator_ColumnVarNameInTable="columnProgramName" msprop:Generator_ColumnPropNameInRow="ProgramName" msprop:Generator_ColumnPropNameInTable="ProgramNameColumn" msprop:Generator_UserColumnName="ProgramName" type="xs:string" />
                                <xs:element name="Type" msdata:DataType="ProcParserFilters.DataProgram._Base.SqlProgramType, ProcParserFilters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" msdata:Caption="Typ" msprop:Generator_ColumnVarNameInTable="columnType" msprop:Generator_ColumnPropNameInRow="Type" msprop:Generator_ColumnPropNameInTable="TypeColumn" msprop:Generator_UserColumnName="Type" type="xs:anyType" />
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:choice>
            </xs:complexType>
            <xs:unique name="SqlProgramDescriptorKey1" msdata:PrimaryKey="true">
                <xs:selector xpath=".//mstns:SqlProgramDescriptor" />
                <xs:field xpath="mstns:ProgramName" />
            </xs:unique>
        </xs:element>
    </xs:schema>

     


    Vote here for a Microsoft Connect feedback channel on Windows - and win a better Windows!

    Wednesday, June 1, 2011 9:55 AM
  • Well, you've definitely got a lot of extra useless stuff in your .xsd. Unfortunately, the DataDesigner adds all that in there and since you're not even using it for database access, I'd re-work it a bit (I'd re-work it even if you *were* using it for database access because I don't believe in using those darn TableAdapters).

    Anyway, see my blog posts for a way of creating a cleaner .xsd without all that extra database TableAdapter stuff in there (which, IMHO, does not belong there ... Visual Studio introduced that in VS2005, VS2003 did NOT have it and the .xsd's were *much* cleaner).

    http://geek-goddess-bonnie.blogspot.com/2010/04/create-xsd.html

    In that blog post, there's also a link to an earlier post I wrote against TableAdapters. You might want to read that one too because I talk about why your DataSet should know nothing about where it gets its data from.

    Let me know if that helps!


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Wednesday, June 1, 2011 3:17 PM
  • Hi BetterToday,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

     

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by ChinaZhang Saturday, September 15, 2012 3:14 AM
    • Unproposed as answer by ChinaZhang Saturday, September 15, 2012 3:14 AM
    Tuesday, June 7, 2011 2:18 AM
    Moderator
  • Hi, BonnieB

    I have the very similar XSD file and got the same issue. Could you point out where is wrong in the XSD file?

    Thanks in advance!
    Saturday, September 15, 2012 3:15 AM
  • I don't know ... get rid of all that TableAdapter junk that gets generated and it might be easier to see what the problem is. Did you read my blog posts that I linked to?

    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Saturday, September 15, 2012 5:03 AM
  • In the meantime I found a new solution for myself:

    If my data isn't connected to any database, I don't use typed datasets (XSD files) anymore. They come with a huge overhead that's not required anyway if you don't access a database.

    My new solution is to use a generic list, like:

    List<Customers> customers = new List<Customers>;

    The new solution works pretty much the same for me. IntelliSense is excellent. I couldn't find any drawbacks yet.

    With the new LinQ to SQL solution (O/R mapper files) typed datasets seem outdated to me anyway.

    If I need a Primary Key for my list, I'm using a Dictionary collection in place of a List collection:

    Dictionary<int, Customers> customers = new Dictionary<int, Customers>;

    HTH


    Vote here for a Microsoft Connect feedback channel on Windows - and win a better Windows!
    Vote here for a consistent keyboard shortcut support in Visual Studio and other Microsoft products!


    • Edited by BetterToday Saturday, September 15, 2012 11:31 AM
    Saturday, September 15, 2012 11:28 AM
  • I agree that if you're never getting any of the data you need from a database, then a Generic List or Dictionary is a better option. Of course, then I wonder where your data is coming from, but that's another topic!  ;0)

    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Saturday, September 15, 2012 6:37 PM