问题描述
嗨
我遇到了一个错误,Google上的匹配数为0(零).这是一个不好的信号.
这是代码
公共静态字符串ToJson(此对象obj)
{{
MemoryStream流=新的MemoryStream();
串行化器.WriteObject(流,obj);
try
{ ());最终
{
stream.Close();
}
}
我正在序列化的对象具有[DataContract(命名空间="...")),因为它来自WCF服务.在错误消息上没有搜索结果,我很受困扰.
请帮助.
谢谢
Hi
I'm getting an error and there are 0 (ZERO) hits on google. This is a bad sign.
here's the code
public static string ToJson(this object obj)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer( obj.GetType() );
MemoryStream stream = new MemoryStream();
serializer.WriteObject( stream, obj );
try
{
return Encoding.UTF8.GetString( stream.ToArray() );
}
finally
{
stream.Close();
}
}
the object that i'm serializing has [DataContract(Namespace="...")] since this is coming from a WCF service.
This was working a moment ago. Without search hits on the error message i'm pretty stuck.
Please help.
Thanks
推荐答案
这篇关于DataContractJsonSerializer“遇到意外的名称空间"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!