when I try to connect with the TcpDuplex Protocol I get a System.Runtime.Remoting.RemotingException. The problem is that the application tries to connect to itself. With two separate applications everything works just fine.
I used this code:
var hProtocolServer = new TcpDuplexServerProtocolSetup(Versioning.Lax, 5000, new NullAuthenticationProvider(), false);
hProtocolServer.CompressionMethod = CompressionMethod.None;
var hHost = new ZyanComponentHost("ZyanHost", hProtocolServer);
var hProtocolSetup = new TcpDuplexClientProtocolSetup(Versioning.Lax, false);
hProtocolSetup.CompressionMethod = CompressionMethod.None;
var hUrl = hProtocolSetup.FormatUrl("localhost", 5000, "ZyanHost");
FConnection = new ZyanConnection(hUrl, hProtocolSetup);
I need this for my unit-tests.
When I use the TcpCustom protocol it works. Is this a bug or is it technically not possible for an application to connect to itself with the TcpDuplex protocol?
OS is Windows 8.1, .NET Framework 4.5.
Thanks in advance
Dec 4, 2014 at 6:54 PM
This is a known limitation of TcpEx channel: it can't work as both a client and a server in one application domain.
For unit tests and application profiling, I recommend using NullChannel designed specifically for that purpose.
NullChannel has minimal possible overhead because it skips message serialization and deserialization stages.
Other channels, like simplex Tcp and Ipc, can also be used instead of TcpEx.