The operation ‘*************Async’ 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.

We were getting Below given error in all our environments except one.

Searching on net gave various reasons for this error like : DataContract if used in WCF Service then gives exception if you return with primitive type etc…

None of those criteria fit it as it was working fine in One CRM environment.

Reason
for this error was that Plugin was built against .Net framework 4.5 but servers Giving error had framework 4.0.

So to resolve
this we can either upgrade server to 4.5 (as it worked in one environment with Framework 4.5) or we can Build plugins against Framework 4.0.

“The operation ‘*************Async’ 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.”

The Web Service plug-in failed in OrganizationId: d7e722c9-6fa5-4bac-8ec3-05174cd4c8db; SdkMessageProcessingStepId: eb06f709-1ecd-e211-bd85-00155d885d81; EntityName: ******; Stage: 40; MessageName: Create; AssemblyName: ****************************, ************.Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c1b635ad77c3aa7c; ClassName: *****************; Exception: Unhandled Exception: System.InvalidOperationException: The operation ‘*************Async’ 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.

   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.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.ChannelFactory1.CreateChannel(EndpointAddress address, Uri via)

   at System.ServiceModel.ClientBase1.CreateChannel()

   at System.ServiceModel.ClientBase1.CreateChannelInternal()

   at System.ServiceModel.ClientBase1.get_Channel()

   at *****************.BusinessProcess.EmailService.Service1SoapClient.*****************.BusinessProcess.EmailService.Service1Soap.SendSingleEMAIL(SendSingleEMAILRequest request)

   at *****************.BusinessProcess.EmailService.Service1SoapClient.SendSingleEMAIL(String userName, String password, String mobileNumber, String contenet)

   at *****************.BusinessProcess.XrmNew_Email.SendMessage(new_Email EmailContext, IOrganizationService service)

   at *****************.Plugins.PostEMAILCreateSendEMAIL.ExecutePostEMAILCreate(LocalPluginContext localContext)

   at *****************.Plugins.Plugin.Execute(IServiceProvider serviceProvider)

   at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)

   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

2 Comments

  1. Gonzalo

    Wow thanks alot, have been dealing with this problem for hours, really thank you 🙂

    Reply
  2. Gonzalo

    Wow thanks alot, have been dealing with this problem for hours, really thank you 🙂

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *