c# - 将对象传递给 WCF 端点
问题描述
我有一个 WCF 服务,它有一个服务方法,它接受一个 object[] 类型的参数。我想根据各种工作流程传递不同种类的对象。当我尝试传递从基本对象类型继承的任何具体对象时,我收到以下错误:
'Error in line 1 position 446. Element
'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data of the
'http://schemas.datacontract.org/2004/07/...' data contract. The deserializer has no knowledge of any
type that maps to this contract. Add the type corresponding to '...' to the list of known types - for
example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed
to DataContractSerializer.'
问题
如何将任何类型的普通旧对象传递给 WCF 服务并在 WCF 服务方法中解释(转换为)我想要的类型?
在高层次上,我想做的是将普通类型对象的实例传递给 WCF。这甚至可能吗?
解决方案
推荐阅读
- python - HTTP ERROR 500...它是服务器错误还是应用程序中的问题?
- reactjs - 在反应中有条件地导出函数组件时,我无法访问我的 useState 变量。任何解决方案?
- checkbox - 我正在尝试减少网格中的复选框宽度但无法减少
- opengl - 如何在 glfw3 中使用 glut 原语?
- java - 如何使用 MaterialShapeDrawable 模仿 MaterialCardView 的视觉效果
- javascript - 如何在 dhtmlx 甘特图中设置日期、年份等行的自动高度
- python - 我如何查看某人的余额?
- python-3.x - 使 if 语句不关心大小写
- reactjs - 从 graphql 获取数据以做出反应
- c++ - C++ 模板和函数重载