By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,595 Members | 3,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,595 IT Pros & Developers. It's quick & easy.

Problem with xsd codegen after installing .net framework srvice pa

P: n/a
I followed the excellent MSDN article "Code Generation in the .NET Framework
Using XML Schema" [1] to build a substitute for the limited xsd.exe. My code
works fine under .NET framework 1.1, but after installing .net framework
service pack 1, my code breaks.

Below are trivial example files that demonstrate the problem:

XSD FILE aaa.xsd
----------------------
<?xml version="1.0" encoding="UTF-8"?>

<schema targetNamespace="urn:ietf:params:xml:ns:aaa"
xmlns:aaa="urn:ietf:params:xml:ns:aaa"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

<complexType name="aaa">
</complexType>

</schema>

XSD FILE bbb.xsd
----------------------
<?xml version="1.0" encoding="UTF-8"?>

<schema targetNamespace="urn:ietf:params:xml:ns:bbb"
xmlns:bbb="urn:ietf:params:xml:ns:bbb"
xmlns:aaa="urn:ietf:params:xml:ns:aaa"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

<import namespace="urn:ietf:params:xml:ns:aaa"
schemaLocation="aaa.xsd"/>

<element name="test"/>

</schema>
And here is the code which I use to process the above schema files (taken
almost line for line from the MSDN article mentioned above [1], but with the
addition of the ability to read multiple xsd files):

xsdCodeGen.cs
----------------------
string[] xsdFiles = { "aaa.xsd", "bbb.xsd" };
XmlSchemas schemas = new XmlSchemas();

// Load the XmlSchema and its collection
foreach(string filename in xsdFiles)
{
XmlSchema xsd;
using(FileStream fs = new FileStream(filename, FileMode.Open,
FileAccess.Read))
{
xsd = XmlSchema.Read(fs, null);
xsd.Compile(null);
}
schemas.Add(xsd);
}

// Create the importer for these schemas
XmlSchemaImporter importer = new XmlSchemaImporter(schemas);

// System.CodeDom namespace for the XmlCodeExporter to put classes in
CodeNamespace ns = new CodeNamespace("testNamespace");
XmlCodeExporter exporter = new XmlCodeExporter(ns);

// Iterate schema top-level elements and export code for each
foreach(XmlSchema xsd in schemas)
{
foreach (XmlSchemaElement element in xsd.Elements.Values)
{
// Import the mapping, and export the code
XmlTypeMapping mapping = importer.ImportTypeMapping(element.QualifiedName);
exporter.ExportTypeMapping(mapping);
}
}
The above code works fine pre- service pack, but post- service pack the line:

XmlTypeMapping mapping = importer.ImportTypeMapping(element.QualifiedName);

will throw the following exception:

Exception: The datatype 'urn:ietf:params:xml:ns:bbb:aaa' is missing.
Any ideas why the different behaviour pre- and post- service pack, and how
to fix?

Many thanks in advance,

Ceri Williams

[1]
http://msdn.microsoft.com/XML/Buildi...xsdcodegen.asp
Nov 12 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Hi Ceri,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you have .net framework installed
ImportTypeMapping throws an exception which says a datatype is missing. If
there is any misunderstanding, please feel free to let me know.

Thanks for providing me with the code you're using. I have tried it on my
machine, which I have .net framework 1.1 sp1 installed on it already.
However, I could not reproduce it. It works fine on my computer without any
exceptions. Could you try this code on another computer to see if it works?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #2

P: n/a
Hi Kevin,

Just to confirm:

I built a machine from scratch, Windows XP Professional, Visual Studio .NET
2003, .NET framework 1.1. Compiling and running the code sample I gave
earlier, everything works fine.

I then install the .NET framework 1.1 Service Pack 1 [1]. I rebuild the
code, compiles fine, but this time I get the runtime exception:
"The datatype 'urn:ietf:params:xml:ns:bbb:aaa' is missing."

I've done nothing else interesting to that machine, not installed anything
else, I set it up purely to test my example code.

Cheers,
Ceri

[1] http://msdn.microsoft.com/netframewo...s/default.aspx
"Kevin Yu [MSFT]" wrote:
Hi Ceri,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you have .net framework installed
ImportTypeMapping throws an exception which says a datatype is missing. If
there is any misunderstanding, please feel free to let me know.

Thanks for providing me with the code you're using. I have tried it on my
machine, which I have .net framework 1.1 sp1 installed on it already.
However, I could not reproduce it. It works fine on my computer without any
exceptions. Could you try this code on another computer to see if it works?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #3

P: n/a
Hi Ceri,

Thanks for your comfirming. To avoid carelessness, I tried it again. I set
up a new computer and followed the steps you have provided. And then tried
with the code in your first post. However, I didn't reproduced it either
this time.

Here I have attached a zip file with a compiled exe file inside. Please try
to run it to see if the Form can be displayed without any exception.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #4

P: n/a
Hi Kevin,

Thanks for looking into this for me, much appreciated. Unfortunately I get
the same exception when I run your test app:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: The datatype
'urn:ietf:params:xml:ns:bbb:aaa' is missing.
at
System.Xml.Serialization.XmlSchemaImporter.FindDat aType(XmlQualifiedName name)
at System.Xml.Serialization.XmlSchemaImporter.FindTyp e(XmlQualifiedName
name)
at System.Xml.Serialization.XmlSchemaImporter.ImportT ype(XmlQualifiedName
name, Type desiredMappingType, Type baseType)
at
System.Xml.Serialization.XmlSchemaImporter.ImportD erivedTypes(XmlQualifiedName baseName)
at
System.Xml.Serialization.XmlSchemaImporter.ImportE lementType(XmlSchemaElement
element, String identifier, Type desiredMappingType, Type baseType, String ns)
at
System.Xml.Serialization.XmlSchemaImporter.ImportE lement(XmlSchemaElement
element, String identifier, Type desiredMappingType, Type baseType, String
ns, Boolean topLevelElement)
at
System.Xml.Serialization.XmlSchemaImporter.ImportE lement(XmlQualifiedName
name, Type desiredMappingType, Type baseType)
at
System.Xml.Serialization.XmlSchemaImporter.ImportD erivedTypeMapping(XmlQualifiedName name, Type baseType, Boolean baseTypeCanBeIndirect)
at
System.Xml.Serialization.XmlSchemaImporter.ImportT ypeMapping(XmlQualifiedName
name)
at WindowsApplication2.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
WindowsApplication2
Assembly Version: 1.0.1734.28382
Win32 Version: 1.0.1734.28382
CodeBase:
file:///E:/Poptel/XSD%20Code%20Gen%20SP1%20Fix/Test%20App%20from%20Kevin%20Yu/WindowsApplication2.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Just to be clear, what steps did you follow when building your test machine?
Did you install the .NET framework (pre-patch) seperately, or did you just
work with the framework as installed by Visual Studio .NET 2003?
Let me know exactly what stages you carried out and I'll re-create it on a
fresh test machine, just to be sure we're following exactly the same steps.

Cheers,
Ceri
"Kevin Yu [MSFT]" wrote:
Hi Ceri,

Thanks for your comfirming. To avoid carelessness, I tried it again. I set
up a new computer and followed the steps you have provided. And then tried
with the code in your first post. However, I didn't reproduced it either
this time.

Here I have attached a zip file with a compiled exe file inside. Please try
to run it to see if the Form can be displayed without any exception.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #5

P: n/a
I just wanted to chime in and say that I am having the exact same problem.
I extended the same code sample and it has been working fine for months. I
installed sp1 an I get the same error.

I have tested it on another machine that also ran the SP with the same
results. But the code still run fine on a machine that does not have SP1.

Any help would be greatly appreciated since we rely heavily on this tool.

Thanks,
Mark
"Kevin Yu [MSFT]" wrote:
Hi Ceri,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you have .net framework installed
ImportTypeMapping throws an exception which says a datatype is missing. If
there is any misunderstanding, please feel free to let me know.

Thanks for providing me with the code you're using. I have tried it on my
machine, which I have .net framework 1.1 sp1 installed on it already.
However, I could not reproduce it. It works fine on my computer without any
exceptions. Could you try this code on another computer to see if it works?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #6

P: n/a
Hi Ceri,

I am working with the .net framework installed by Visual Studio .NET 2003.
I think the two packs are all the same with the version v1.1.4322.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #7

P: n/a
Hi Ceri,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #8

P: n/a
Hi Kevin,

Thanks again for helping look into this. Unfortunately the problem is still
occurring - I have tried again to build a machine from scratch using the
steps described in my previous post, and I still get the same problems. It
was interesting to see the other post from Mark Andrews, which suggests it
probably isn't a problem unique to my operating environment.

Since you have been unable to repeat the problem in your environment, what
do you think is the best way to proceed? Can I suggest I re-build my test
machine using Virtual PC, then send you the Virtual PC image on the machine
so you can mess around with it?

Let me know if you think this is a good idea,

Cheers,
Ceri
"Kevin Yu [MSFT]" wrote:
Hi Ceri,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #9

P: n/a
Hi Ceri,

Looking at the nature of this issue, it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/default...d=sz;en-us;top. If this is not
an urgent issue and your would like us to create an incident for you and
have Microsoft Customer Service Representative contact you directly, please
send email to (remove "online." from this no Spam email address):
mailto:ds******@online.microsoft.com with the following information,

*Include "Followup: <Tomcat IssueID>" in the email Subject.
*Location of the post
*Subject Line
*First Name, Last Name
*MSDN Subscriber ID
*Company name (if any)
*Phone number
*e-mail address

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #10

P: n/a
Hi Kevin,

Thanks for your help with this. I have opened a technical support incident
now with Microsoft, hopefully get the problem fixed via that route.

Cheers,
Ceri
"Kevin Yu [MSFT]" wrote:
Hi Ceri,

Looking at the nature of this issue, it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/default...d=sz;en-us;top. If this is not
an urgent issue and your would like us to create an incident for you and
have Microsoft Customer Service Representative contact you directly, please
send email to (remove "online." from this no Spam email address):
mailto:ds******@online.microsoft.com with the following information,

*Include "Followup: <Tomcat IssueID>" in the email Subject.
*Location of the post
*Subject Line
*First Name, Last Name
*MSDN Subscriber ID
*Company name (if any)
*Phone number
*e-mail address

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #11

P: n/a
You're welcome, Ceri.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.