问题描述:
c# 引用webservice ,在执行调用过程中:
QTMIntegrationService.WebServiceQTMSoapClient client = new HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoapClient();
client.QTMIntegrationService(xmldoc.InnerXml, machinetype, testtype);
调用时,提示: The operation 'getSoapAsync' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.
系统异常日志:
-----------------------------异常信息 Start-----------------------------
当前时间:2015-05-23 12:00:33
异常消息:The operation 'QTMIntegrationServiceAsync' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.
异常对象:System.ServiceModel
调用堆栈:at System.ServiceModel.Dispatcher.OperationFormatter.Validate(OperationDescription operation, Boolean isRpc, Boolean isEncoded)
at System.ServiceModel.Dispatcher.OperationFormatter..ctor(OperationDescription description, Boolean isRpc, Boolean isEncoded)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter..ctor(OperationDescription description, DataContractFormatAttribute dataContractFormatAttribute, DataContractSerializerOperationBehavior serializerFactory)
at System.ServiceModel.Description.DataContractSerializerOperationBehavior.GetFormatter(OperationDescription operation, Boolean& formatRequest, Boolean& formatReply, Boolean isProxy)
at System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
at System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch)
at System.ServiceModel.Description.DispatcherBuilder.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime)
at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters)
at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
at System.ServiceModel.ChannelFactory.CreateFactory()
at System.ServiceModel.ChannelFactory.OnOpening()
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ChannelFactory.EnsureOpened()
at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannelInternal()
at System.ServiceModel.ClientBase`1.get_Channel()
at HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoapClient.HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoap.QTMIntegrationService(QTMIntegrationServiceRequest request) in d:\Visual Studio 2012\HLQTMIntegration\HLTestSyncIntegration\Service References\QTMIntegrationService\Reference.cs:line 131
at HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoapClient.QTMIntegrationService(String strxml, String machineType, String testType) in d:\Visual Studio 2012\HLQTMIntegration\HLTestSyncIntegration\Service References\QTMIntegrationService\Reference.cs:line 140
at HLTestSyncIntegration.TestSyncService.HandlelabQTM() in d:\Visual Studio 2012\HLQTMIntegration\HLTestSyncIntegration\TestSyncService.cs:line 185
触发方法:Void Validate(System.ServiceModel.Description.OperationDescription, Boolean, Boolean)
-----------------------------异常信息 End-----------------------------
开发环境:Win7 64位,.NET 4.5,VS2012
运行环境:Win7 32位,.NET 4.0
问题原因:开发环境有4.5,运行环境没有,导致的问题。安装了.NET 4.5 ,问题解决。
原文地址:http://q.cnblogs.com/q/72045/