Search

XmlSerializer Code Generation component cannot handle nested unbounded elements when there is only one element by mohanmg

Closed
as Won't Fix Help for as Won't Fix

2
0
Sign in
to vote
Type: Bug
ID: 471297
Opened: 6/29/2009 10:24:35 PM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
XmlSerializer Code Generation component: It cannot handle the xsd definitions that have only one element and the occurence of the element is unbounded.


<complexType name="pType">
     <sequence>
    <element name="Par" type="tns:nType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>

The following thread discusses this issue in detail.
http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/e33305c3-b5f6-4922-8a3f-df202088d25a
Details (expand)
Product Language
English

Version

.NET Framework 3.5
Operating System
Windows XP Professional
Operating System Language
English
Steps to Reproduce
Generate stub code from the xsd and wsdl got from the web server
Create a web service client
Invoke a web service request by calling an operation.
Actual Results
Unhandled Exception: System.ServiceModel.CommunicationException: There was an error in serializing one of the headers in message xxx: 'Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'xxx.ServiceReference1.xxxType[]'
to 'xxx.ServiceReference1.xxxType'
error CS0029: Cannot implicitly convert type 'xxx.ServiceReference1.xxxType' to 'xxx.ServiceReference1.xxxType[]'

Please see InnerException for more details. ---> System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'xxx.ServiceReference1.xxxType[]' to 'xxx.ServiceReference1.xxxType'

System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompiler
Parameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] typ
es, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assem
bly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String
defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type
type)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerati
onContext.GenerateSerializers()
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerati
onContext.GetSerializer(Int32 handle)
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_He
aderSerializer()
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.AddHeadersToMessage(Message
message, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
--- End of inner exception stack trace ---

Server stack trace:
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.AddHeadersToMessage(Message
message, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.SerializeRequest(MessageVersion messageVe
rsion, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.BeforeRequest(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.PrepareCall(ProxyOperationRuntime operation, Bo
olean oneway, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperat
ionRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperat
ionRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCal
l, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Expected Results
A successful call to the web server and getting the result.
TAP Code (if applicable)
 
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

Sign in to post a comment.
Posted by Microsoft on 7/14/2009 at 2:59 PM
This is a known issue in the XmlSerializer. To avoid the risk of regression we are only fixing customer blocking issues in the XmlSerializer. You can work around this issue by adding a dummy attribute to the XML schema that you generate the serialization code from.

Thank you

Daniel Roth
Program Manager
Posted by mohanmg on 7/14/2009 at 2:00 AM
This bug does not happen when there are more than 1 elements in the complexType. Even for the case when there is just one element with maxOccurs=unbounded, the bug does not happen always. There is a specific pattern for which this bug happens.


Posted by Frank D Xu on 7/8/2009 at 9:37 PM
Please advise if the fix is availiable.
Does this bug happen when there are more than 1 elements, and the maxOccurs is unbounded?

eg.
<complexType name="pType">
<sequence>
    <element name="Par" type="tns:nType" minOccurs="0" maxOccurs="unbounded"/>
    <element name="Xyz" type="tns:nType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
Posted by Microsoft on 7/1/2009 at 12:11 AM
Thanks for your feedback. We are routing this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Sign in to post a workaround.