当我调用我的WCF服务时收到下面提到的错误?我如何摆脱它?
尝试序列化参数时发生错误http://tempuri.org/:MyWCFSvc.svc InnerException消息是'Type ' System.String [] ' with data contract name ' ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays ' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.' . 有关更多详细信息,请参阅InnerException . *
我尝试在我的WCF服务接口中使用[ServiceKnownType(typeof(string []))]但没有运气
4 回答
晚了一年,但我有同样的问题,这是你需要做的
问题是当您使用类的类型构造序列化程序时,序列化程序不会将其视为一个arrray,它只能看到一个对象 .
如果通过这样做首先找到它:
我也遇到了同样的问题,但在使用
[ServiceKnownType(typeof(string[]))]
和[ServiceKnownType(typeof(int[]))]
确认问题后,将OperationContract定为问题 .例如:
没有理由让KnownType成为一个字符串数组 . 序列化程序应该已经知道了,并且数组不是问题 . 我在WCF中移动列表没有问题 . 你能发表你正在做的代表性样本吗?
在客户端上配置服务引用提供了“数据类型”选项,允许您为集合/字典类型指定不同的类型 . 你有什么设置?