THRIFT-3000 .NET implementation has trouble with mixed IP modes
Client: C#
Patch: sharpdevel <icode666@github> & Jens Geyer

This closes #377
This closes #452

This commit effectively establishes .NET 4.5 as a requirement for C#. Trying to build for earlier platform versions will fail. If that turns out to become a problem we should address this with a subsequent ticket.

TcpListener and TcpClient are created based on the capabilities of the used runtime framework. For windows the changes automatically handle IPv4 and IPv6 sockets. In mono it behaves as before.

When using TcpListener and TcpClient it depends on the network configuration if IPv4 or IPv6 is used. By upgrading the framework to .NET 4.5 the DualMode can be set on the sockets of the listener and the client. The sockets then try to establish IPv6 sockets before they fallback to IPv4
diff --git a/lib/csharp/test/Multiplex/Client/MultiplexClient.csproj b/lib/csharp/test/Multiplex/Client/MultiplexClient.csproj
index 6221e14..ff78723 100644
--- a/lib/csharp/test/Multiplex/Client/MultiplexClient.csproj
+++ b/lib/csharp/test/Multiplex/Client/MultiplexClient.csproj
@@ -28,7 +28,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>MultiplexClient</RootNamespace>
     <AssemblyName>MultiplexClient</AssemblyName>
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <IsWebBootstrapper>false</IsWebBootstrapper>
     <FileUpgradeFlags>
diff --git a/lib/csharp/test/Multiplex/Server/MultiplexServer.csproj b/lib/csharp/test/Multiplex/Server/MultiplexServer.csproj
index dc1d123..6a8177e 100644
--- a/lib/csharp/test/Multiplex/Server/MultiplexServer.csproj
+++ b/lib/csharp/test/Multiplex/Server/MultiplexServer.csproj
@@ -28,7 +28,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>MultiplexServer</RootNamespace>
     <AssemblyName>MultiplexServer</AssemblyName>
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <IsWebBootstrapper>false</IsWebBootstrapper>
     <FileUpgradeFlags>
diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs
index ec0696a..b54d09d 100644
--- a/lib/csharp/test/ThriftTest/TestClient.cs
+++ b/lib/csharp/test/ThriftTest/TestClient.cs
@@ -185,14 +185,14 @@
 
             // linear distribution, unless random is requested
             if (!randomDist) {
-                for (var i = 0; i < initLen; ++i) { 
+                for (var i = 0; i < initLen; ++i) {
                     retval[i] = (byte)i;
                 }
                 return retval;
             }
 
             // random distribution
-            for (var i = 0; i < initLen; ++i) { 
+            for (var i = 0; i < initLen; ++i) {
                 retval[i] = (byte)0;
             }
             var rnd = new Random();
@@ -270,13 +270,13 @@
                     if (binIn[ofs] != binOut[ofs])
                         throw new Exception("testBinary: content mismatch at offset " + ofs.ToString());
             }
-            catch (Thrift.TApplicationException e) 
+            catch (Thrift.TApplicationException e)
             {
                 Console.Write("testBinary(" + BytesToHex(binOut) + "): "+e.Message);
             }
 
             // binary equals? only with hashcode option enabled ...
-            if( typeof(CrazyNesting).GetMethod("Equals").DeclaringType == typeof(CrazyNesting)) 
+            if( typeof(CrazyNesting).GetMethod("Equals").DeclaringType == typeof(CrazyNesting))
             {
                 CrazyNesting one = new CrazyNesting();
                 CrazyNesting two = new CrazyNesting();
diff --git a/lib/csharp/test/ThriftTest/ThriftTest.csproj b/lib/csharp/test/ThriftTest/ThriftTest.csproj
index d671997..5f9f151 100644
--- a/lib/csharp/test/ThriftTest/ThriftTest.csproj
+++ b/lib/csharp/test/ThriftTest/ThriftTest.csproj
@@ -28,7 +28,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>ThriftTest</RootNamespace>
     <AssemblyName>ThriftTest</AssemblyName>
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <IsWebBootstrapper>false</IsWebBootstrapper>
     <FileUpgradeFlags>
@@ -136,6 +136,6 @@
 for %25%25I in ("%25OUTPUT_DIR%25") do set SHORT_DIR=%25%25~fsI
 for %25%25I in ("%25THRIFT_FILE%25") do set THRIFT_SHORT=%25%25~fsI
 "$(ProjectDir)\..\..\..\..\compiler\cpp\thrift.exe" --gen csharp -o %25SHORT_DIR%25 %25THRIFT_SHORT%25
-$(MSBuildToolsPath)\Csc.exe /t:library /out:"$(ProjectDir)ThriftImpl.dll" /recurse:"$(ProjectDir)gen-csharp"\* /reference:"$(ProjectDir)..\..\src\bin\Debug\Thrift.dll"</PreBuildEvent>
+"$(MSBuildToolsPath)\Csc.exe" /t:library /out:"$(ProjectDir)ThriftImpl.dll" /recurse:"$(ProjectDir)gen-csharp"\* /reference:"$(ProjectDir)..\..\src\bin\Debug\Thrift.dll"</PreBuildEvent>
   </PropertyGroup>
 </Project>
\ No newline at end of file