Error: not supported in the WCF testing client because it uses the type System.Threading.Tasks

I will post this question, although I see that there are several others like this. However, I cannot find a satisfactory solution for any reason why I get this error and how to solve it.

So, today I had to host the service on my local computer for testing. The service is one WCF service solution, and it works, as far as I know, for a long time. However, when I downloaded the project and tried to host this service on my local computer, I got an error from the header:

This operation is not supported in the WCF test client because it uses the System.Threading type

So, when I returned home, I decided to make a service using some asynchronous methods and figure it out. However, I was very surprised when I get this same error on an almost empty project that does not use (or at least seems to be) System.Threading.Tasks anywhere.

So what I did:

  • New WCF Service Created Using Visual Studio 2013 Default Template
  • Left default file IService1.cs and Service1.svc
  • Changed IService1.cs to:

     using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace WcfService { [ServiceContract] public interface IService1 { [OperationContract] int GetEmpId(int id); } } 
    • Changed Service1.svc to:

      using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text;

      namespace WcfService {public class Service1: IService1 {public int GetEmpId (int id) {return id; }}}

And leaving the default web.config , which looks like this:

 <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the values below to false before deployment --> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <protocolMapping> <add binding="basicHttpsBinding" scheme="https" /> </protocolMapping> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> 

I didn’t even try to use Task , Threading or something like that, I just wanted to see that my service was up and running, so I can start adding things and see exactly when I get the error but, to my surprise, after installing Service1.svc as my launch class and trying to start the project, I got the same error:

This operation is not supported in the WCF test client because it uses the System.Threading type

OK, now I'm completely lost. I got this error after several attempts to start my project. Before posting this question, I tried again, and this time I did not get an error. Actually, I just finished my client, and I can use the GetEmpId() method.

So what is going on here. This is a screenshot when creating my project:

Service

I do not have a GetEmpIdAsync() method. I did not try to add it. And how does this happen, it will not build several times, and now suddenly I can use the method that I actually implemented from the very beginning?

+8
c # wcf
source share
1 answer

WCF automatically exposes a synchronous and asynchronous interface for each of your methods. Both of these methods call GetEmpId synchronously on the server side, the difference is to expect the result to be synchronous or asynchronous on the client side.

If you made your class

 public class Service1 : IService1 { public Task<int> GetEmpIdAsync(int id) { return Task.FromResult<int>(id); } } 

you will still see int GetEmpId(int id) in the test tool. WCF is smart enough to map two versions to the same function.

The β€œerror” you see is only a limitation of the test tool that comes with visual studio, both functions call the same function on the server side, so there is no convincing force to force Microsoft to add support. There is no actual error. If you really want to test the asynchronous version, you will need to write your own test client that calls this function.

+9
source share

All Articles