When trying to pass Exception as Fault from server down to client, only in debug mode, the exception can’t be serialized, error message is:
System.Runtime.Serialization.SerializationException: Type ‘System.Collections.ListDictionaryInternal’ with data contract name ‘ArrayOfKeyValueOfanyTypeanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays’ is not expected. Add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Reason is describe in reference 1, the the solution/work around from reference 2 is better. As reference 2 explained, this is a side effect from debugger. If debugging is disable in WCF host, we don’t get this problem.
Here is the post from MSDN describing how to enable the auto-attach WCF host process in debug mode. Note: the default debug flag for new WCF service is off.
<system.web> <!-- default was off, so auto-attach won't work. --> <compilation debug="true" /> <system.web>
What I figured out is developer also has to make sure in the WCF project property window, the servers url is correct in the web tab.