Abhinav Ranjan
Abhinav Ranjan

Reputation: 146

WCF Service Failing With Web Application but working fine in WinForm

Unhandled Exception: System.InvalidOperationException: The operation 'GetCountAsync' 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.

Hi, I am getting above exception while trying to Call webservice (which I don't have any control on).

I've checked various blogs but they all say that we can't have DataContract of a type and return primitive type in webservice. but in my case service works fine in various scenarios but fails in some.

  1. Same service and code was working fine in another environment (web application).
  2. I am calling GetCount() not GetCountAsync() in my code.
  3. Same code works in a winform application but fails in web application in same machine.

Any pointers to solve this issue is appreciated.

Thanks, Abhinav

Upvotes: 1

Views: 584

Answers (2)

R. de Veen
R. de Veen

Reputation: 73

Building the solution with .NET Framework 4.0 and running it with 4.0 works. Building with 4.5 and running on 4.0 gives this error.

Upvotes: 0

Abhinav Ranjan
Abhinav Ranjan

Reputation: 146

The Issue was with Framework version. Application built on framework 4.5 was working fine in first environment but breaking in the second as it had Framework 4.0. :)

Upvotes: 1

Related Questions