This project is read-only.

If you have a Security Context on the server

Mar 19, 2009 at 3:48 AM
Edited Mar 19, 2009 at 3:50 AM
Our server requires a Security Context, so we had some trouble getting the sample code to work.
What we realised, is that we need to add a NetTcpBinding to the CustomBinding - not build up all the elements from scratch ourselves as is done in the samples (the SecurityBindingElement - caused the main difficulty).

The code looks something like this (modified from

// Create a custom binding based on NetTcp
CustomBinding compressedTcpBinding = new CustomBinding(new NetTcpBinding());

// Find the current MessageEncoding binding and its position in the BindingElement stack
var currentEncoder = compressedTcpBinding.Find<BinaryMessageEncodingBindingElement>();
int encoderIndex = compressedTcpBinding.Elements.IndexOf(currentEncoder);

// Add it to the stack instead of the current encoder.
compressedTcpBinding.Elements.Insert(encoderIndex, new CompressionBindingElement());