Hello, here's the setup for the project.

I have a WCF Service that is hosted on a net.tcp binding in buffered mode and ReliableSession enabled.

The binding is configured to use TransportWithMessageCredential security. The certificate is a self signed certificate that I am identifying using the Thumbprint. The UserNameValidator is a custom validator which for testing, never fails (it wasn't failing before but I removed the uncertainty)

The service and client are on the same machine and they both have access to the certificate.

The problem:

I am receiving a Socket Aborted exception when trying to consume a Method from the service. Here is the code I use to open a connection to the service. MonitorServiceCallbacks only contains empty methods to fulfil the requirements of the Interface.

_instanceContext = new InstanceContext(new MonitorServiceCallbacks());
 _serviceInterface = new MonitorCallbackServiceClient(_instanceContext);

 _serviceInterface.ClientCredentials.UserName.UserName = Environment.MachineName;
 _serviceInterface.ClientCredentials.UserName.Password = "myPassword";
 _serviceInterface.Open();

This appears to work fine as the _serviceInterface.State variable is set to State.Opened and the custom validator is called and returns without exception.

However, if I try to call a method using the _serviceInterface proxy, no code that I can break into is run on the service and the tracelog reveals no errors apart from a SocketAborted exception which occurs 1 minute after receiving what appears to be the message for the method.

There is no InnerException.

I have tried to google the issue but the results tend to say "just disable security and it will work fine". Unfortunately, this cannot be done.

I am extremely confused by this issue and any help would be greatly appreciated.

Managed to solve this one myself after a bit of Head -> Wall bashing :)

For future reference this was actually a serialisation error.
The object I was trying to send to the service inherited from the data contract. So I was trying to send a cast down to the data contract to the service.
WCF doesn't appear to allow this.

I forgot that not only the service can have tracing enabled. Enabling client side tracing earlier would have saved me a lot of time.

I was attempting to do the following:

_serviceInterface.Register((MyDataContract)MyParentObject, aVariable, anotherOne);

What I needed to do:

MyDataContract tempContract = MyParentObject.CreateMyDataContract();
    _serviceInterface.Register(tempContract, aVariable, anotherOne);
    /* Note: MyParentObject.CreateMyDataContract() is my own method which creates an instance
    of the MyDataContract and copies the relevant information to it */
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.