diff --git a/OpenTK/Platform/Configuration.cs b/OpenTK/Platform/Configuration.cs index 3bd7fdd1f..7bb2b71f9 100644 --- a/OpenTK/Platform/Configuration.cs +++ b/OpenTK/Platform/Configuration.cs @@ -28,6 +28,7 @@ using System; using System.Reflection; using System.Runtime.InteropServices; +using System.Net.Sockets; namespace OpenTK { @@ -102,6 +103,13 @@ namespace OpenTK { // So we hack around and prevent them ever being initalised. // TODO: only seems to work before .NET 4.0, not sure if still needed by then + HACK_PerfCounters(); + + // Another issue with ipv6 DNS resolution delaying downloads for 30-40 seconds too + HACK_IPv6(); + } + + static void HACK_PerfCounters() { try { Assembly assem = typeof(System.Net.IPAddress).Assembly; Type perfType = assem.GetType("System.Net.NetworkingPerfCounters"); @@ -111,7 +119,20 @@ namespace OpenTK { if (field == null) return; field.SetValue(null, true); - } catch { + } catch { + } + } + + static void HACK_IPv6() { + try { + // Force socket state to get initalised + bool ignored = System.Net.Sockets.Socket.OSSupportsIPv6; + + FieldInfo field = typeof(Socket).GetField("s_OSSupportsIPv6", BindingFlags.NonPublic | BindingFlags.Static); + if (field == null) return; + + field.SetValue(null, false); + } catch { } } }