发出 WCF 服务请求时出现类型转换错误
我正在开发一个项目,该项目向我认为是 WCF 服务的请求。当我尝试发出请求并运行程序时,我收到此错误堆栈跟踪:
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
任何人都可以帮助我理解此错误的确切含义吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您尝试将
array[] 类型
转换为type
时出现错误。尝试检查您获得的源值。
By the error you are trying to convert an
array[] type
to atype
.Try checking the source value you are getting.
https://learn.microsoft。 com/en-us/troubleshoot/system-center/orchestrator/unable-generate-temporary-class
http://ddkonline.blogspot.com/2010/ 07/wcf-client-proxy-deserialization-issue.html
解决方法基本上是将与服务引用相关的 Reference.cs 文件中的多维数组更改为单维。
特定位置引用
https://learn.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