发出 WCF 服务请求时出现类型转换错误

发布于 2025-01-11 06:03:47 字数 7315 浏览 0 评论 0原文

我正在开发一个项目,该项目向我认为是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫儰鉨ミ守葔 2025-01-18 06:03:47

由于您尝试将 array[] 类型 转换为 type 时出现错误。
尝试检查您获得的源值。

By the error you are trying to convert an array[] type to a type.
Try checking the source value you are getting.

镜花水月 2025-01-18 06:03:47

当 svcutil.exe 或 Web 服务
描述语言工具(Wsdl.exe)用于生成客户端
信息。当您发布包含嵌套节点的架构时
将 maxOccurs 属性设置为“无界”值,这些工具
在生成的 datatypes.cs 文件中创建多维数组。
因此,生成的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
解决方法基本上是将与服务引用相关的 Reference.cs 文件中的多维数组更改为单维。

特定位置引用

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

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://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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文