Exception while calling WCF method in Thread

155 views Asked by At

i have an unsual issue and so far Google hasn't been any help at all.

I have setup a DUPLEX client connection to a WCF Server using WSDualHttpBinding, this works fine. I then placed the client connection in a thread and now i receive this exception (Message, Stack, InnerException):

the thread was being aborted. bei System.ServiceModel.Channels.SecurityBindingElement..ctor() [14948]
bei System.ServiceModel.MessageSecurityOverHttp.CreateSecurityBindingElement(Boolean isSecureTransportMode, Boolean isReliableSession, MessageSecurityVersion version) [14948] bei System.ServiceModel.WSDualHttpBinding.CreateBindingElements() [14948] bei System.ServiceModel.Channels.Binding.EnsureInvariants(String contractName) [14948] bei System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose) [14948] bei System.ServiceModel.ChannelFactory.OnOpening() [14948] bei System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) [14948] bei System.ServiceModel.ChannelFactory.EnsureOpened() [14948] bei System.ServiceModel.DuplexChannelFactory1.CreateChannel(InstanceContext callbackInstance, EndpointAddress address, Uri via) [14948] bei System.ServiceModel.ClientBase1.CreateChannel() [14948] bei System.ServiceModel.ClientBase1.CreateChannelInternal() [14948]
bei System.ServiceModel.ClientBase
1.get_Channel()

The class method that sets up the connection and calls the method is called as follows:

await Task.Run(() => new ClientConnector().LoadIT());

The setup is as follows (in the LoadIT method):

 try
            {
                var FXDuplexCallback = new FXDuplexCallback();
                FXDuplexCallback.ServiceCallbackEvent += HandleServiceCallbackEvent;

                var instanceContext = new InstanceContext(FXDuplexCallback);
                var dualHttpBinding = new WSDualHttpBinding();

                dualHttpBinding.ReceiveTimeout = TimeSpan.MaxValue;
                dualHttpBinding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue;
                dualHttpBinding.SendTimeout = new TimeSpan(00, 00, 03);
                dualHttpBinding.CloseTimeout = TimeSpan.MaxValue;

                var endpointAddress = new EndpointAddress(sServiceEndpointUri);
                oProxy = new FXDuplexProxy(instanceContext, dualHttpBinding, endpointAddress);

                //Start client connection with OpenTF and receive current user data.
                oRoomData = oProxy.FXClientConnect();
            }
            catch (Exception e)
            {
                Debug.WriteLine("e.Message + e.StackTrace + e.InnerException);
                oProxy.Abort();
            }

FXDuplexProxy is the class which inherits from DuplexClientBase<the server contract interface>

I have no idea why this exception only happens while i run the conneciton in a thread, does anyone have any ideas?

0

There are 0 answers