使用Web方法ASP.NET获取从基类继承的自定义对象时出错

时间:2021-12-22 01:40:05

I have created a base class A and a class B is a derived class inherited from class A. Both classes are marked as Serialized. When I try to return an object of type B through a web method i am getting following error:

我创建了一个基类A,而一个类B是从类A继承的派生类。这两个类都标记为Serialized。当我尝试通过Web方法返回类型B的对象时,我收到以下错误:

System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type CSI.API.RPartyMembershipInfo was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

System.Web.Services.Protocols.SoapException:System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.InvalidOperationException:生成XML文档时出错。 ---> System.InvalidOperationException:不期望CSI.API.RPartyMembershipInfo类型。使用XmlInclude或SoapInclude属性指定静态未知的类型。

Any help would be appreciated.

任何帮助,将不胜感激。

1 个解决方案

#1


1  

You will need to post your code before we can provide some help.

在我们提供一些帮助之前,您需要发布您的代码。

I did a quick search for the final line of the error message in Google and got these 2 pages which might be of help.

我快速搜索了Google中错误消息的最后一行,得到了这两页可能有所帮助。

http://www.theserverside.net/discussions/thread.tss?thread_id=37823

http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/aa18e76b-0efc-4c5c-be28-5fb578cf47f2/

#1


1  

You will need to post your code before we can provide some help.

在我们提供一些帮助之前,您需要发布您的代码。

I did a quick search for the final line of the error message in Google and got these 2 pages which might be of help.

我快速搜索了Google中错误消息的最后一行,得到了这两页可能有所帮助。

http://www.theserverside.net/discussions/thread.tss?thread_id=37823

http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/aa18e76b-0efc-4c5c-be28-5fb578cf47f2/