I’m implementing reconnection mechanism for WCF service proxy (NetTcpBinding) in Silverlight. Operations of the service is called parallely by a timer. Implementation is very simple (like here), but form time my application failes with exception:
Uncaught Error: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure(Exception exception, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.Socket.DoResolve(DnsEndPoint dnsep, SocketAsyncEventArgs usersArgs)
at System.Net.Sockets.Socket.StaticResolveCallback(Object args)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Does anybody know what is the source of the problem and how to solve it?
i’ve used dns-name of the server. As a result, when I connect next time, WCF core is trying to resolve dns-name and if dns is not available wcf core throws SocketException:
and wcf core become in invalid state. When some operation is called, wcf-core failes as described in the question.
Use ip-adress (not dns-name) for tcp binding