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. 2 2839
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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
by: San |
last post by:
Hi,
Why strongly named assembly can refer other strongly named assembly ?
Thanks with Regards,
San.
|
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...
|
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...
|
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 -
|
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...
|
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...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |