System.InvalidOperationException: 生成 XML 文档时出错。 ---> System.InvalidOperationException: 不应是类型 Space.Entity.SpaceDepartment。使用 XmlInclude 或 SoapInclude 属性静态指定非已知的类型。 在 System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType) 在 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) 在 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write8_ArrayOfAnyType(Object o) 在 Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer) 在 System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) --- 内部异常堆栈跟踪的结尾 --- 在 System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) 在 System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o) 在 System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue) 在 System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream) 在 System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues) 在 System.Web.Services.Protocols.WebServiceHandler.Invoke()
注:其中webservices方法的返回值为:IList.
解决方法参考:http://chocoboboy.spaces.live.com/blog/cns!1983ad9c55f2f5c7!323.entry?wa=wsignin1.0