0
我在一個序列化對象實現使用Web服務已經工作,數據將通過一個桌面應用程序我去的web服務跟隨操作執行消耗和正常工作:爲什麼反序列化不起作用?
[WebMethod]
public byte[] getPartners()
{
string[] strFiles = Directory.GetFiles(GlobalStatic.rootAppData + @"\partners");
List<DentalSock.main.partner> _partners = new List<DentalSock.main.partner>();
foreach (String str in strFiles)
{
DentalSock.main.partner ptn = new DentalSock.main.partner();
ptn.readPartner(str.Replace(GlobalStatic.rootAppData + @"\partners\", "").Replace(".xml", ""));
_partners.Add(ptn);
}
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, _partners);
return ms.ToArray();
}
然後,當我回到客戶端消費者我稱之爲web服務對象序列化到一個通用的列表下面的代碼:
ServiceReference1.partnerSoapClient p = new ServiceReference1.partnerSoapClient();
byte[] byteArray = p.getPartners();
MemoryStream stream = new MemoryStream(byteArray, 0, byteArray.Length);
stream.Write(byteArray, 0, byteArray.Length);
BinaryFormatter bf = new BinaryFormatter();
pList = (List<partner>)bf.Deserialize(stream);
一切似乎很好地工作,但在反序列化方法被調用沒有最後一行發生,沒有例外,當我試着調試器進入調試器時模式時,黃色突出顯示的行到達上面的代碼的最後一行只是停止並顯示窗口的形式! 請幫助這個原因我不明白!