PC Review


Reply
Thread Tools Rate Thread

Bug with namespaces in XSD.EXE /dataset (C#)

 
 
Marc Durdin
Guest
Posts: n/a
 
      13th Dec 2007
I have come across an issue with XSD.exe code generation (in /dataset mode,
version 2.0.50727.1432), relating to namespaces. Specifically, certain types
are not always consistently prefixed with global::, so if you have a
namespace with the name System, the generated code will fail to compile.

The issue can occur specifically in two lines of the generated code, first
in the Add*Row function:

public SomeTableRow AddSomeTableRow(System.DateTime SomeDateTimeField) {

Which should be:

public SomeTableRow AddSomeTableRow(global::System.DateTime
SomeDateTimeField) {

And in the property get/set for any datetime field:

public System.DateTime SomeDateTimeField {

Which should be:

public global::System.DateTime SomeDateTimeField {

WORKAROUND

Don't use a namespace called System. We came across this because we are
generating database class libraries for a legacy system which included a
"system" 'namespace' in the data objects...

ISSUE REPRODUCTION

To reproduce this issue, take the following sample XSD:

<?xml version="1.0" standalone="yes"?>
<xs:schema id="DateTimeBug" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DateTimeBugDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="DateTimeBug">
<xs:complexType>
<xs:sequence>
<xs:element name="DateTimeField" type="xs:dateTime"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Generate a C# file with XSD:
xsd /dataset /n:MyCompany.Data.DateTimeBuggy datetimebug.xsd

Include the following namespace in second C# file:

namespace MyCompany.Data.System { };

Compile a project with these two C# files. It will fail with the error "The
type or namespace name 'DateTime' does not exist in the namespace
'MyCompany.Data.System' (are you missing an assembly reference?)"

(originally misposted to microsoft.public.data.ado ... oops)
 
Reply With Quote
 
 
 
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      14th Dec 2007
Hello Marc,
Thanks for your posting.

I reproduced this issue on my side. VS IDE throw the error message
"'DataTime' doesn't exist in 'MyCompany.DataSystem' namespace" when
compiling. I agree with you. It seems XSD.exe forget to add prefix global::
for System.DataTime. We need perform further research. I will update here
as soon as possible. If you have any more concern, please also feel free to
post here.

Thanks again for your understanding.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      17th Dec 2007
Hello Marc,
Thanks for your waiting.

I have logged this issue in our DB for Visual Studio product team to
investigate.
The issue is that XSD.exe doesn't generate prefix "global::" for
System.DataTime. Thereby, project will failed to be compiled, due to
namespace conflict. The workaround is not use a namespace called System in
your project. Another way is to specify the prefix "global::" for
System.DataTime type manually. Thanks again for your post. This will
benefit our product quality improvement very much.

But I'm afraid this issue may not be fixed very soon.
For urgent issues, we can contact Microsoft CSS directly.
If the problem is confirmed to be a product bug, the case charge will be
free.
You can check http://support.microsoft.com for regional support phone
numbers.

You can also post the issue to our Connect feedback portal. Our developer
will evaluate them seriously and communicate with you directly on the issue
there.
http://connect.microsoft.com/VisualStudio/

Improving the quality of our products and services is a never ending
process for Microsoft.
Please also feel free to let me know if you have any more concern on this
issue. It's my pleasure to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Marc Durdin
Guest
Posts: n/a
 
      17th Dec 2007
Thank you. We have gone ahead and worked around the issue by special-casing
our MyCompany.Data.System namespace!

Glad to be of assistance in improving product quality - and equally glad to
see Microsoft's responsiveness here.

Regards,

Marc

"WenYuan Wang [MSFT]" wrote:

> Hello Marc,
> Thanks for your waiting.
>
> I have logged this issue in our DB for Visual Studio product team to
> investigate.
> The issue is that XSD.exe doesn't generate prefix "global::" for
> System.DataTime. Thereby, project will failed to be compiled, due to
> namespace conflict. The workaround is not use a namespace called System in
> your project. Another way is to specify the prefix "global::" for
> System.DataTime type manually. Thanks again for your post. This will
> benefit our product quality improvement very much.
>
> But I'm afraid this issue may not be fixed very soon.
> For urgent issues, we can contact Microsoft CSS directly.
> If the problem is confirmed to be a product bug, the case charge will be
> free.
> You can check http://support.microsoft.com for regional support phone
> numbers.
>
> You can also post the issue to our Connect feedback portal. Our developer
> will evaluate them seriously and communicate with you directly on the issue
> there.
> http://connect.microsoft.com/VisualStudio/
>
> Improving the quality of our products and services is a never ending
> process for Microsoft.
> Please also feel free to let me know if you have any more concern on this
> issue. It's my pleasure to assist you.
>
> Have a great day,
> Best regards,
>
> Wen Yuan
> Microsoft Online Community Support
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      18th Dec 2007

The pleasure is all mine.
Thanks for your understanding, Marc.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GAC and namespaces Neil Microsoft ASP .NET 1 15th Dec 2009 03:30 PM
DataSet Designer and Namespaces daokfella Microsoft ASP .NET 1 25th Jun 2007 06:54 PM
define Namespaces for Dataset in ASP.NET Web Projects for VisualStudio 2005 m.roello@dev.it Microsoft ASP .NET 0 25th Jan 2006 02:02 PM
Typed dataset and namespaces Magne Ryholt Microsoft ADO .NET 2 11th Apr 2005 03:26 PM
VC 7.1 Bug with namespaces Christoph Rabel Microsoft VC .NET 2 13th Aug 2003 08:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:11 AM.