I\'ve got a simple WCF service that has worked fine while I\'ve been testing on my dev machine.
Now I\'ve moved the web service to a web server, and I\'m running the
Just faced the exact same problem but it was caused by security protocol type hardcoded to TLS 1.2
while the service was deployed to 2008 server without R2 (and 32 bit to boot, which means non-upgradable to R2).
This is a very unlikely scenario for anyone else, but thought I'd mention.
If anyone is in the same situation and has a line of code like this, you know why you are getting the error now:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
Late answer to the party, but I got the same error.
Turns out, you cannot use abstract classes for data contract members. I had to use the following:
[DataContract]
public class MyClass {
[DataMember]
public A MyProperty { get; set; }
}
[DataContract]
[KnownType(typeof(B))]
[KnownType(typeof(C))]
public class A {
}
[DataContract]
public class B : A {
}
[DataContract]
public class C : A {
}
In order to allow WCF to serialize something like
var myClass = new MyClass();
myClass.MyProperty = new B();
WCF also needs to have concrete classes to pass data around (since it all needs to be XML-serializable and must be capable of being expressed in XML schema - interfaces aren't well suited).
I believe it won't be able to pass back an IEnumerable<T>
- try using a List<T>
(or an T[]
array) or a concrete type instead.
Any luck?
I had the same problem because I was returning an insanely large amount of record from the server, i added the following line to my wcf config file and it worked.
<system.web>
<httpRuntime maxRequestLength ="262144" executionTimeout="103600"/>
</system.web>
Update your Entity if any changes made in your previous tables and didn't update your entity also this error will occur
Don't define MyClass as Serializable. Mark it as [DataContract] and it's properties as [DataMember].
If you can't, well... I think I've seen that question lying around here as well.
EDIT
While there is nothing inherently blocking [Serializable] will cause your serialization to perhaps process more than it can handle.
EDIT 2
marc_s's comment got it right