473,418 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

strongly-typed dataset datatable constructor's are marked as inter

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" msdata:DataType="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.
Jul 21 '05 #1
2 2840
There is a way around this problem. Generate proxy class inside your
dll that creates the table and passes it back to the calling function.

Something like this:
public class Proxy
{
public static PersonalitiesDataTable GetPersonalitiesDataTable ()
{
PersonalitiesDataTable ret = new PersonalitiesDataTable();
return ret;
}
}

and use the static methods of this class from your client code instead
of trying to instantiate PersonalitiesDataTable directly.

By the way, my company also has a product calls WF BusinessComponent
that you can use to load a XML schema to a dataset at design-time. Take
a look at http://www.wirefactor.com. The production release will be out
soon.

Thanks,
-Al

theWizK wrote:
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" msdata:DataType="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.


Jul 21 '05 #2
Absolutely. Thanks for smacking me into reality. I've done this before in
the Java world, but didn't even think about it. Guess sometimes you're
thinking to hard about the problem, and you miss the simplest solutions.

Thanks a bunch, Al.

Kendal

"al*****@yahoo.com" wrote:
There is a way around this problem. Generate proxy class inside your
dll that creates the table and passes it back to the calling function.

Something like this:
public class Proxy
{
public static PersonalitiesDataTable GetPersonalitiesDataTable ()
{
PersonalitiesDataTable ret = new PersonalitiesDataTable();
return ret;
}
}

and use the static methods of this class from your client code instead
of trying to instantiate PersonalitiesDataTable directly.

By the way, my company also has a product calls WF BusinessComponent
that you can use to load a XML schema to a dataset at design-time. Take
a look at http://www.wirefactor.com. The production release will be out
soon.

Thanks,
-Al

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jack Menendez | last post by:
I have a forms based plugin architecture using C# that includes help files using MSHelpServices. However, my strongly named assemblies cannot be created because Interop.MSHelpServices is not strongly...
4
by: Tamir Khason | last post by:
I have a form. On form there is my control (all of control's assemblies signed by strong key), BUT while running I recieve he located assembly 'MyFooAssembly' is not strongly named. While...
1
by: San | last post by:
Hi, Why strongly named assembly can refer other strongly named assembly ? Thanks with Regards, San.
5
by: Oleg Subachev | last post by:
When I try to use strongly named assembly1 that references non-strongly named assembly2 I get the following error: "The located assembly '<assembly2 name>' is not strongly named." How can I...
2
by: Paul Ingles | last post by:
Hi, I have an ASP.NET Web Application which uses a number of controls in an external strongly named assembly. Whenever I view a page that uses one of the controls within the strongly named...
1
by: DotNetJunkies User | last post by:
I have a .NET DLL that uses ADO 2.8 DLL. I am not able to "strongly name" the .NET DLL. Any comments, work arounds ? CHDe --- Posted using Wimdows.net NntpNews Component -
0
by: john | last post by:
The changes to asp.net makes it very difficult for us to migrate one of our web projects to 2.0 and makes deployments more difficult for us. It seems that the new Asp.net model is only designed...
5
by: Harold Howe | last post by:
I am having a problem deserializing objects from a library when the following conditions exist: 1- The library is strongly named 2- The serialized file was created with version 1.0 of the...
0
by: EricBlair | last post by:
I have two weakly named third party DLL's that I want to convert to STRONGLY named DLL's so I can register them in the GAC. I'm not getting how to do this. The stuff I've seen seems to suggest...
0
by: Dave Burns | last post by:
Hi, I have a C++ managed assembly (.dll) which links to a bunch of native libraries. Everything works fine if I don't make the managed assembly a strongly named one. Once I make it a strongly...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.