处理无效的UTF-8字节所需的操作

时间:2016-06-29 13:03:45

标签: c# wcf serialization utf-8 utf-16

我们正面临从应用程序的事件日志中识别的问题,此错误不可重现。错误是这样的:

System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://WebsiteName/:genUpdateObj. The InnerException message was 'There was an error deserializing the object of type NameSpaceName.RequestClassName. 'ڵj��d�f�' contains invalid UTF8 bytes.'. Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type NameSpacName.ClassName. 'ڵj��d�f�' contains invalid UTF8 bytes. ---> System.Xml.XmlException: 'ڵj��d�f�' contains invalid UTF8 bytes. ---> System.Text.DecoderFallbackException: Unable to translate bytes [FC] at index 3 from specified code page to Unicode.

将请求对象反序列化为WCF服务合同方法的类对象时,这是错误的。我们有这样的WCF运营合同:

public ResponseClass MethodName(RequestClassName genUpdateObj)
{
    //Service operations
}

看起来类string的{​​{1}}属性之一具有无效的UTF-8字符。 我需要一些帮助来在我们的服务器端WCF服务中启动一些良好的预防性代码机制。

0 个答案:

没有答案