I am working on a project that makes request to what I think is a WCF service. When I am trying to make the requests and run the program I get this error stack trace:
Unhandled Exception: System.ServiceModel.CommunicationException: There was an error in serializing body of message GetFilingListRequest: 'Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType'
error CS0030: Cannot convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType'
error CS0030: Cannot convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType'
error CS0029: Cannot implicitly convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]'
error CS0029: Cannot implicitly convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]'
error CS0029: Cannot implicitly convert type 'FilingReviewServiceTest.FilingReviewService...'. Please see InnerException for more details. ---> System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType'
error CS0030: Cannot convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType'
error CS0030: Cannot convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType'
error CS0029: Cannot implicitly convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]'
error CS0029: Cannot implicitly convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]'
error CS0029: Cannot implicitly convert type 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType' to 'FilingReviewServiceTest.FilingReviewService.AllowanceChargeType[]'
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly 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.SerializerGenerationContext.GenerateSerializers()
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32 handle)
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_BodySerializer()
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Security.SecurityAppliedMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Security.SecurityAppliedMessage.OnWriteMessage(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
at System.ServiceModel.Channels.MtomMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset, String startInfo, String boundary, String startUri, Boolean writeMessageHeaders)
at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message, Boolean shouldRecycleBuffer)
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPort.GetFilingList(GetFilingListRequest request)
at FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPortClient.FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPort.GetFilingList(GetFilingListRequest request) in C:\dev\eFile_IL\C# Program\FilingReviewServiceTest\FilingReviewServiceTest\Connected Services\FilingReviewService\Reference.cs:line 116471
at FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPortClient.GetFilingList(FilingListQueryMessageType FilingListQueryMessage) in C:\dev\eFile_IL\C# Program\FilingReviewServiceTest\FilingReviewServiceTest\Connected Services\FilingReviewService\Reference.cs:line 116477
at FilingReviewServiceTest.Program.Main(String[] args) in C:\dev\eFile_IL\C# Program\FilingReviewServiceTest\FilingReviewServiceTest\Program.cs:line 68
Can anyone help me understand what this error means exactly?
CodePudding user response:
By the error you are trying to convert an array[] type
to a type
.
Try checking the source value you are getting.
CodePudding user response:
This problem occurs when the svcutil.exe or the Web Services Description Language Tool (Wsdl.exe) are used to generate the client information. When you publish a schema that contains nested nodes that have the maxOccurs attribute set to the "unbounded" value, these tools create multidimensional arrays in the generated datatypes.cs file. Therefore, the generated Reference.cs file contains incorrect types for the nested nodes.
https://docs.microsoft.com/en-us/troubleshoot/system-center/orchestrator/unable-generate-temporary-class
http://ddkonline.blogspot.com/2010/07/wcf-client-proxy-deserialization-issue.html
The fix is to basically change the multi-dimensional array in the Reference.cs file related to your service reference to a single dimension.
specific location reference
at FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPortClient.FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPort.GetFilingList(GetFilingListRequest request) in C:\dev\eFile_IL\C# Program\FilingReviewServiceTest\FilingReviewServiceTest\Connected Services\FilingReviewService\Reference.cs:line 116471
at FilingReviewServiceTest.FilingReviewService.FilingReviewMDEPortClient.GetFilingList(FilingListQueryMessageType FilingListQueryMessage) in C:\dev\eFile_IL\C# Program\FilingReviewServiceTest\FilingReviewServiceTest\Connected Services\FilingReviewService\Reference.cs:line 116477
at FilingReviewServiceTest.Program.Main(String[] args) in C:\dev\eFile_IL\C# Program\FilingReviewServiceTest\FilingReviewServiceTest\Program.cs:line 68