Data Type Detection Using Created XSD DataSet

I have an XML Schema Definition (XSD) file in Visual Studio 2010. The DataSet constructor generates a strongly typed dataset in the <name> .designer.vb file

Depending on the number of error factors, it seems to sporadically provide strong typing for enumerated operations (used in LINQ or for each loop)

For example, sometimes the generated code base can detect a type, and sometimes not:

screenshot

The offensive code seems to be whether the generated file has a function:

 Public Overridable Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator Return Me.Rows.GetEnumerator End Function 

If so, then calling the enumerator for the function will return a boring object .
If this is not the case, the enumerator will return the appropriate type.

My question is:

How can I get it to consistently generate appropriate behavior?

Our source code does not contain the generated code, so each developer should generate it for himself. This causes some machines to get compiler errors with incorrect typing, while others not ... with the same source code.

Some things that seem to have something to do with it:

  • Client-oriented assembly version of .NET 4.0 VS.NET 4.0
  • Regardless of whether the XSD, designer, or use files are open during generation
  • Others?

Possible workarounds:

  • Enable strong typing / casting with all ads
  • Include correctly generated file in source control
+1
source share
1 answer

Problem:

In short, the problem occurs when the MSDataSetGenerator tool is MSDataSetGenerator , but the System.Data.DataSetExtensions assembly is not yet loaded into the current Visual Studio process.

Decision:

One way to load the assembly is to simply open any XSD file, and THEN to create the developer code.

The following steps should generate the appropriate constructor file:

  • Open any XSD file in the designer view (this will load DataSetExtensions.dll )
  • Right click on XSD and select Run Custom Tool

Here's a complete step-by-step walkthrough with photos of problems and solutions.

Other instances:

This issue was reported by Microsoft in the following big tickets:

It is also addressed in the SO question:

0
source

Source: https://habr.com/ru/post/1332473/


All Articles