我有這個類從web服務生成:有一個未封閉的文字字符串。 1號線,位置12284
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class RequestMessage
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:ihe:iti:xds-b:2007", Order=0)]
public Helper.RequestType Request;
public RequestMessage() {
}
}
我試圖通過創建一個XmlDocument:
XmlDocument xReq = new XmlDocument();
DataContractSerializer serializer = new DataContractSerializer(typeof(RequestMessage));
using (MemoryStream memStm = new MemoryStream())
{
using (XmlWriter xw = XmlWriter.Create(memStm))
{
//xnameSpace.Add("ns0", "urn:ihe:iti:xds-b:2007");
serializer.WriteObject(xw, oReq);
memStm.Position = 0;
xReq.Load(memStm);
}
}
但我得到一個錯誤: 「有一個未封閉的字符串,第1行,位置12284.」 on「xReq.Load(memStm);」線。
我使用UTF-8編碼,但我讀過,是「XmlSerializerNamespaces」的默認..
什麼可以是問題?