本文介绍了...可能不能在这种情况下使用...而序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号..我有 webservice 和 WebMethod
I've webservice and WebMethod
[webMethod]
[XMLInclude(typeof(ContractCar[]))
public object GetObjects(Cars[] cars)
{
return Translator.ToObjects(Facade.GetObjects(cars);
}
public static object GetObjects(Cars cars)
{
List<Car> cars =new List<Country(...fillingcollection)
return cars.ToArray(),
}
public static object ToObjects(object collection)
{
if(collection is Car[])
{
return ConvertModelCarsToContractCars(collection),
}
public ContractCar[] ConvertModelCarsToContractCars(Cars[] collection)
{
...there is rewriting pool...
}
我在客户端遇到异常:
生成 XML 文档时出错.
There was an error generating the XML document.
我正在使用这个函数来检查我将发送给客户端的集合并且它可以工作.
I'm using this function to check collection which I would send to the client and it works.
public static void SerializeContainer(object obj)
{
try
{
// Make sure even the construsctor runs inside a
// try-catch block
XmlSerializer ser = new XmlSerializer(typeof(object));
TextWriter w = new StreamWriter(@"c:\list.xml");
ser.Serialize(w, obj);
w.Close();
}
catch (Exception ex)
{
DumpException(ex);
}
}
有趣的是当集合只有一个元素时 [webmethod] 工作正常,但当更多时它会坏
推荐答案
我把object
改成了objects[]
.
这篇关于...可能不能在这种情况下使用...而序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论