472,986 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 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 2807
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.