我的問題類似於this但有一個有趣的區別。我已經明確定義了所有的值,但它仍然無效。如果可能的話,我也嘗試避免契約屬性。WCF客戶端在明確定義枚舉值時失敗
所以它看起來像什麼。 我定義了一個具有枚舉類型屬性的合同。枚舉是
public enum ErrorCodes
{
GeneralError = 1,
ValidationError = 2,
AuthenticationError = 3
}
然後客戶端無法與errror:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to http://localhost/MyTestAppService/SomeService.svc/soap. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at MyTestApp.ISomeService.TestMethod(TestRequest request)
當我刪除所有明確的值,它的工作原理:
public enum ErrorCodes
{
GeneralError,
ValidationError,
AuthenticationError
}
您是否按照鏈接問題裝飾了[EnumMember(Value =「1」)]'的枚舉? – Tim
不,我試圖避開它 – neleus
爲什麼?問題的根本原因很可能是序列化錯誤,那麼爲什麼要避免'[DataContract]'屬性系列? – Tim