Dmitry Borovsky
Dmitry Borovsky

Reputation: 558

WCF reconnection in Silverlight

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?

Upvotes: 1

Views: 499

Answers (1)

Dmitry Borovsky
Dmitry Borovsky

Reputation: 558

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:

    System.Net.dll!System.Net.Dns.GetAddrInfo(string name = "myhost.com") + 0x200 bytes 
    System.Net.dll!System.Net.Dns.InternalGetHostByName(string hostName, bool includeIPv6) + 0x90 bytes 
    System.Net.dll!System.Net.Sockets.Socket.DoResolve(System.Net.DnsEndPoint dnsep, System.Net.Sockets.SocketAsyncEventArgs usersArgs = {System.Net.Sockets.SocketAsyncEventArgs}) + 0x72 bytes    
    System.Net.dll!System.Net.Sockets.Socket.StaticResolveCallback(object args) + 0x6f bytes    
    mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3d bytes 
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0x97 bytes    
    mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x5b bytes 
    mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x199 bytes  
    mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 bytes 

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

Upvotes: 1

Related Questions