在本机开发环境测试, 没有任何异常.
[DataContract]
[KnownType(typeof(ErrorResponse))]
class ApiResponse {........}
class ErrorResponse {.............}
一切正常, 返回errorresponse
但是将网站连同wcf.svc一起发布至windows server 2008之后, 访问接口之后就提示无法序列化, 需要用knowntype, 这是怎么回事?
可能的原因是什么? 我实在是没头绪了.
错误:
Request Error
The server encountered an error processing the request. The exception message is 'Cannot serialize parameter of type 'Lib.Api.Model.Responses.ErrorResponse' (for operation 'logout', contract 'IDataService') because it is not the exact type 'Lib.Api.Model.Responses.ApiResponse' in the method signature and is not in the known types collection. In order to serialize the parameter, add the type to the known types collection for the operation using ServiceKnownTypeAttribute.'. See server logs for more details. The exception stack trace is:
........
........
stack trace
........
他提示需要用serviceknowntype, 难道必须这样? 不能写knowntype在数据契约上? 但是我在开发环境一切正常啊. drives me crazy!!!
------解决方案--------------------
'logout'怎么定义的