diff --git a/test/csharp/TestClient.cs b/test/csharp/TestClient.cs
index fad1057..17e5978 100644
--- a/test/csharp/TestClient.cs
+++ b/test/csharp/TestClient.cs
@@ -33,7 +33,7 @@
 {
     public class TestClient
     {
-        private class TestParams
+        public class TestParams
         {
             public int numIterations = 1;
             public string host = "localhost";
@@ -44,6 +44,7 @@
             public bool framed;
             public string protocol;
             public bool encrypted = false;
+            public bool multiplexed = false;
             protected bool _isFirstTransport = true;
 
 
@@ -105,21 +106,30 @@
         private const int ErrorStructs = 2;
         private const int ErrorContainers = 4;
         private const int ErrorExceptions = 8;
+        private const int ErrorProtocol = 16;
         private const int ErrorUnknown = 64;
 
         private class ClientTest
         {
+            private readonly TestParams param;
             private readonly TTransport transport;
+            private readonly SecondService.Client second;
             private readonly ThriftTest.Client client;
             private readonly int numIterations;
             private bool done;
 
             public int ReturnCode { get; set; }
 
-            public ClientTest(TestParams param)
+            public ClientTest(TestParams paramin)
             {
+                param = paramin;
                 transport = param.CreateTransport();
-                client = new ThriftTest.Client(param.CreateProtocol(transport));
+                TProtocol protocol = param.CreateProtocol(transport);
+                if (param.multiplexed)
+                {
+                    second = new SecondService.Client(new TMultiplexedProtocol(protocol, "SecondService"));
+                }
+                client = new ThriftTest.Client(protocol);
                 numIterations = param.numIterations;
             }
             public void Execute()
@@ -148,7 +158,7 @@
 
                     try
                     {
-                        ReturnCode |= ExecuteClientTest(client);
+                        ReturnCode |= ExecuteClientTest(client, second, param);
                     }
                     catch (Exception ex)
                     {
@@ -215,12 +225,12 @@
                         {
                             numThreads = Convert.ToInt32(args[++i]);
                         }
-                        else if (args[i] == "--compact" || args[i] == "--protocol=compact")
+                        else if (args[i] == "--compact" || args[i] == "--protocol=compact" || args[i] == "--protocol=multic")
                         {
                             param.protocol = "compact";
                             Console.WriteLine("Using compact protocol");
                         }
-                        else if (args[i] == "--json" || args[i] == "--protocol=json")
+                        else if (args[i] == "--json" || args[i] == "--protocol=json" || args[i] == "--protocol=multij")
                         {
                             param.protocol = "json";
                             Console.WriteLine("Using JSON protocol");
@@ -230,6 +240,11 @@
                             param.encrypted = true;
                             Console.WriteLine("Using encrypted transport");
                         }
+
+                        if (args[i].StartsWith("--protocol=multi"))
+                        {
+                            param.multiplexed = true;
+                        }
                     }
                 }
                 catch (Exception ex)
@@ -296,7 +311,7 @@
             return retval;
         }
 
-        public static int ExecuteClientTest(ThriftTest.Client client)
+        public static int ExecuteClientTest(ThriftTest.Client client, SecondService.Client second, TestParams param)
         {
             int returnCode = 0;
 
@@ -313,6 +328,18 @@
                 returnCode |= ErrorBaseTypes;
             }
 
+            if (param.multiplexed)
+            {
+                Console.WriteLine("secondTestString(\"Test2\")");
+                s = second.secondtestString("Test2");
+              Console.WriteLine(" = \"" + s + "\"");
+              if ("testString(\"Test2\")" != s)
+              {
+                  Console.WriteLine("*** FAILED ***");
+                  returnCode |= ErrorProtocol;
+              }
+            }
+
             Console.Write("testBool(true)");
             bool t = client.testBool((bool)true);
             Console.WriteLine(" = " + t);
