I have an XML Schema Definition (XSD) file in Visual Studio 2010. The DataSet Designer should generate a strongly typed dataset in the <name>.designer.vb
file
Depending on a number of errant factors, it seems to sporadically provide strong typing for enumerable operations (used in LINQ or for each loops)
For instance, sometimes the generated code base is able to detect the type, and sometimes it's not:
The offending code seems to be whether or not the generated file has the function:
Public Overridable Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
If it does, then calling the enumerator for the function will return a boring object
.
If it doesn't, then the enumerator will return the appropriate type.
Our source code doesn't contain generated code, so each developer needs to generate it for themselves. This results in some machines getting compiler errors with improper typing, while others don't... with the same exact source code.
Some things that appear to having something to do with it:
In short, the problem occurs when the MSDataSetGenerator
tool runs, but the System.Data.DataSetExtensions
assembly has not yet been loaded into the current Visual Studio process.
One way to load the assembly is just to open any XSD file and THEN re-generate the designer code.
The following steps should generate the appropriate designer file:
DataSetExtensions.dll
)Run Custom Tool
Here's a full step by step walkthrough with pictures of the issue and solution
This problem has been reported to Microsoft in the following bug tickets:
It is also addressed in the SO Question: