``` c#
// Compile: csc test.cs /r:Zyan.Communication.dll
using System;
using System.Collections;
using System.Linq;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
using Zyan.Communication.Security;
struct Program
{
static void Main(string[] args)
{
if (args.Any())
RunClient(args);
else
RunServer();
}
static void RunServer()
{
var port = 1234;
var auth = new NullAuthenticationProvider();
var protocol = new TcpDuplexServerProtocolSetup(port, auth, true);
using (var host = new ZyanComponentHost("SecureServer", protocol))
{
Console.WriteLine("Server started. Press ENTER to quit");
Console.ReadLine();
}
}
static void RunClient(string[] args)
{
// insecure client
var clientProtocol = new TcpDuplexClientProtocolSetup(false);
using (var conn1 = new ZyanConnection("tcpex://localhost:1234/SecureServer", clientProtocol))
{
Console.WriteLine("Connected to server. Press ENTER to quit.");
Console.ReadLine();
}
}
}
```
Comments: ** Comment from web user: Rainbird **
Another solution could be a little "dirty" workaround. The crypto server sink could pass an empty message with an empty stream via SendEmptyToClient method. The server won´t crash then, but the client will receive an irritating ArgumentNullException ("Parameter '' cannot be null."). If the ParamName of the client side catched exception equals "serializationStream" and, we could assume, this is caused by a pre-formatter-server channel sink. Instead of the ArgumentNullException, ZyanConnection could throw a SerializationException. It is dirty, I now. But it may work. What do you think?
```
// CryptoServerSink
try
{
...
}
catch (CryptoRemotingException)
{
processingResult = SendEmptyToClient
(
transactionStage,
out responseMsg,
out responseHeaders,
out responseStream
);
requestMsg = null;
}
// ZyanConnection
try
{
RemoteDispatcher.Logon(_sessionID, credentials);
_registeredComponents = new List<ComponentInfo>(RemoteDispatcher.GetRegisteredComponents());
_sessionAgeLimit = RemoteDispatcher.SessionAgeLimit;
}
catch (Exception ex)
{
// unregister remoting channel
var registeredChannel = ChannelServices.GetChannel(channelName);
if (registeredChannel != null)
ChannelServices.UnregisterChannel(registeredChannel);
// dispose channel if it's disposable
var disposableChannel = registeredChannel as IDisposable;
if (disposableChannel != null)
disposableChannel.Dispose();
var sinkFailure = ex as ArgumentNullException;
if (sinkFailure != null &&
if (sinkFailure != null &&
ex.Source.Equals("mscorlib") &&
sinkFailure.ParamName.Equals("serializationStream"))
throw new SerializationException();
throw ex.PreserveStackTrace();
}
```