EnjoySharePoint YouTube Channel

Type System.Threading.Tasks.Task1[System.String] cannot be serialized error in WCF

I faced this issue when trying to consume a WCF service in Asp.Net.
The full error message that I got is below:
Type ‘System.Threading.Tasks.Task`1[System.String]’ cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute
Exact cause I also do not know but is related to.Net framework version.
If you are using svcutil to generate the proxy class from the WCF url, then we need to add one more attribute to it and the error will go.
You can follow this article on how to Generate WCF Proxy using SvcUtil.exe.
Here we are using like below:
svcutil /language:cs /out:generatedproxy.cs /config:app.config net.tcp://localhost/Design_Time_Addresses/SLicense/Service1/
Now we need to add the /syncOnly attribute at the end like below:
svcutil /language:cs /out:generatedproxy.cs /config:app.config net.tcp://localhost/Design_Time_Addresses/SLicense/Service1 /syncOnly
The will generate the generatedproxy.cs file. Use this .cs file, the error will not come.
Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →