G
Guest
Hello all.
I have noticed that when I generate a strongly-typed dataset from an xml
schema that the DataTables that are generated have their constructors marked
as internal. What this means is when I try to instantiate one of the
strongly-typed tables from this dataset from a different assembly, I cannot.
Let me provide examples...
If I have a simple dataset like this:
<?xml version="1.0" ?>
<xs:schema id="WebReportPersonalityDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:element name="WebReportPersonalityDataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Personality" msprop:typedName="Personality"
msprop:typedPlural="Personalities">
<xs:complexType>
<xs:sequence>
<xs:element name="PeopleID" type="xs:int" minOccurs="0" />
<xs:element name="Last_Name" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="First_Name" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="Middle_Name" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="FormattedName" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="Confidence" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="DocNum" type="xs:int" minOccurs="0" />
<xs:element name="RefDate" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="Title" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="KeyWords" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="entered_by" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="reviewed_by" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="ApprovedForUse" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="NotApprovedForUse" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="ApprovedForPub" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="rowguid" msdataataType="System.Guid,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
and I run the xsd.exe utility on it, I get a source code file that looks
something like this:
--snip--
//
// This source code was auto-generated by xsd, Version=1.1.4322.573.
//
namespace WebReports.Data {
--snip--
[System.Diagnostics.DebuggerStepThrough()]
public class PersonalitiesDataTable : DataTable,
System.Collections.IEnumerable {
--snip--
internal PersonalitiesDataTable() :
base("Personality") {
this.InitClass();
}
internal PersonalitiesDataTable(DataTable table) :
base(table.TableName) {
if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {
this.CaseSensitive = table.CaseSensitive;
}
if ((table.Locale.ToString() !=
table.DataSet.Locale.ToString())) {
this.Locale = table.Locale;
}
if ((table.Namespace != table.DataSet.Namespace)) {
this.Namespace = table.Namespace;
}
this.Prefix = table.Prefix;
this.MinimumCapacity = table.MinimumCapacity;
this.DisplayExpression = table.DisplayExpression;
}
--snip--
}
--snip--
}
As you can see, the PersonalitiesDataTable class is public, but the
constructors are both marked internal. which means that I can only
instantiate one of these tables directly, from the assembly that contains
this strongly-typed dataset. This is a problem when I've got this dataset as
well as all of my database libraries in one assembly, and I try to use them
from another assebmly (such as my web project).
Has anyone else had problems with this? Is there a way to change this
behavior? My initial thoughts are that the only way I can get around this it
to generate the dataset (in VS.NET) classes and then remove the Custom Tool
Command "MSDataSetGenerator" so that it does not get re-generated. This is a
pain in the rear, however, if I ever want to add or remove columns from the
dataset, or make other modifications. It also means that I've got to check
in this generated source code into source control (which I normally do not
do). Are there any attributes that I can add to the dataset (like some of
the other msdata: and msprop: namespace attributes) to make these public by
default?
Thanks in advance or any suggestions or solutions to my problem.
Kendal.
I have noticed that when I generate a strongly-typed dataset from an xml
schema that the DataTables that are generated have their constructors marked
as internal. What this means is when I try to instantiate one of the
strongly-typed tables from this dataset from a different assembly, I cannot.
Let me provide examples...
If I have a simple dataset like this:
<?xml version="1.0" ?>
<xs:schema id="WebReportPersonalityDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:element name="WebReportPersonalityDataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Personality" msprop:typedName="Personality"
msprop:typedPlural="Personalities">
<xs:complexType>
<xs:sequence>
<xs:element name="PeopleID" type="xs:int" minOccurs="0" />
<xs:element name="Last_Name" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="First_Name" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="Middle_Name" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="FormattedName" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="Confidence" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="DocNum" type="xs:int" minOccurs="0" />
<xs:element name="RefDate" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="Title" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="KeyWords" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="entered_by" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="reviewed_by" type="xs:string" minOccurs="0"
msprop:nullValue="_null" />
<xs:element name="ApprovedForUse" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="NotApprovedForUse" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="ApprovedForPub" type="xs:string"
minOccurs="0" msprop:nullValue="_null" />
<xs:element name="rowguid" msdataataType="System.Guid,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
and I run the xsd.exe utility on it, I get a source code file that looks
something like this:
--snip--
//
// This source code was auto-generated by xsd, Version=1.1.4322.573.
//
namespace WebReports.Data {
--snip--
[System.Diagnostics.DebuggerStepThrough()]
public class PersonalitiesDataTable : DataTable,
System.Collections.IEnumerable {
--snip--
internal PersonalitiesDataTable() :
base("Personality") {
this.InitClass();
}
internal PersonalitiesDataTable(DataTable table) :
base(table.TableName) {
if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {
this.CaseSensitive = table.CaseSensitive;
}
if ((table.Locale.ToString() !=
table.DataSet.Locale.ToString())) {
this.Locale = table.Locale;
}
if ((table.Namespace != table.DataSet.Namespace)) {
this.Namespace = table.Namespace;
}
this.Prefix = table.Prefix;
this.MinimumCapacity = table.MinimumCapacity;
this.DisplayExpression = table.DisplayExpression;
}
--snip--
}
--snip--
}
As you can see, the PersonalitiesDataTable class is public, but the
constructors are both marked internal. which means that I can only
instantiate one of these tables directly, from the assembly that contains
this strongly-typed dataset. This is a problem when I've got this dataset as
well as all of my database libraries in one assembly, and I try to use them
from another assebmly (such as my web project).
Has anyone else had problems with this? Is there a way to change this
behavior? My initial thoughts are that the only way I can get around this it
to generate the dataset (in VS.NET) classes and then remove the Custom Tool
Command "MSDataSetGenerator" so that it does not get re-generated. This is a
pain in the rear, however, if I ever want to add or remove columns from the
dataset, or make other modifications. It also means that I've got to check
in this generated source code into source control (which I normally do not
do). Are there any attributes that I can add to the dataset (like some of
the other msdata: and msprop: namespace attributes) to make these public by
default?
Thanks in advance or any suggestions or solutions to my problem.
Kendal.