【发布时间】:2011-05-01 19:52:54
【问题描述】:
当我将 Silverlight 和 Web 项目分别升级到版本 4 时,我遇到了一个突然暴露的大问题。
由于这样做,我所有的 WCF 服务都失败并显示以下错误消息:
反序列化 Anyboat.Admin.UserService.User 类型的对象时出错。文件意外结束。以下元素未关闭:LastName、AuthenticateUserResult、AuthenticateUserResponse、Body、Envelope。
StackTrace 是:
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.UserServiceClientChannel.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.Anyboat.Admin.UserService.UserService.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.OnEndAuthenticateUser(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
我在我的 SilverlightFaultBehaviour 中的响应消息上设置了一个断点,这是我收到的信封响应。注意 *"\r\n"*
之间的回车"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\r\n <s:Header>\r\n <a:Action s:mustUnderstand=\"1\">urn:UserService/AuthenticateUserResponse</a:Action>\r\n <a:RelatesTo>urn:uuid:07cc1361-c74c-4449-b423-e982d2ac8e05</a:RelatesTo>\r\n </s:Header>\r\n <s:Body>\r\n <AuthenticateUserResponse>\r\n <AuthenticateUserResult xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/AnyBoat.Web.Classes.DataObjects\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <d4p1:Active>true</d4p1:Active>\r\n <d4p1:EmailAddress>robbie@robbietapping.com.au</d4p1:EmailAddress>\r\n <d4p1:FirstName>Robbie</d4p1:FirstName>\r\n <d4p1:IsAdministrator i:nil=\"true\" />\r\n <d4p1:LastName>Tapping</d4p1:LastName>\r\n <d4p1:Password>xxxxxxxxx</d4p1:Password>\r\n <d4p1:UserID>2</d4p1:UserID>\r\n <d4p1:UserName>robbietapping</d4p1:UserName>\r\n </AuthenticateUserResult>\r\n </AuthenticateUserR
esponse>\r\n </s:Body>\r\n</s:Envelope>"
谁能告诉我这个问题是否存在,我将我的 VS2010 升级到 SP1,这已经开始显现了。
任何信息或答案将不胜感激。
谢谢
编辑
发生错误的代码是:
public Anyboat.Admin.UserService.User EndAuthenticateUser(System.IAsyncResult result) {
object[] _args = new object[0];
Anyboat.Admin.UserService.User _result = ((Anyboat.Admin.UserService.User)(base.EndInvoke("AuthenticateUser", _args, result)));
return _result;
}
【问题讨论】:
标签: silverlight wcf deserialization