From cb887dd4b5ce65d63aad9fc9d21444e5aaa31e77 Mon Sep 17 00:00:00 2001 From: lidgren Date: Fri, 24 Dec 2010 08:04:23 +0000 Subject: [PATCH] try-catch added when trying to get MAC address --- Lidgren.Network/NetPeer.Internal.cs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Lidgren.Network/NetPeer.Internal.cs b/Lidgren.Network/NetPeer.Internal.cs index 3dd5750..b60e83a 100644 --- a/Lidgren.Network/NetPeer.Internal.cs +++ b/Lidgren.Network/NetPeer.Internal.cs @@ -94,16 +94,23 @@ namespace Lidgren.Network NetRandom.Instance.NextBytes(macBytes); #if IS_MAC_AVAILABLE - System.Net.NetworkInformation.PhysicalAddress pa = NetUtility.GetMacAddress(); - if (pa != null) - { - macBytes = pa.GetAddressBytes(); - LogVerbose("Mac address is " + NetUtility.ToHexString(macBytes)); - } - else - { - LogWarning("Failed to get Mac address"); - } + try + { + System.Net.NetworkInformation.PhysicalAddress pa = NetUtility.GetMacAddress(); + if (pa != null) + { + macBytes = pa.GetAddressBytes(); + LogVerbose("Mac address is " + NetUtility.ToHexString(macBytes)); + } + else + { + LogWarning("Failed to get Mac address"); + } + } + catch (NotSupportedException) + { + // not supported; lets just kee the random bytes set above + } #endif byte[] epBytes = BitConverter.GetBytes(boundEp.GetHashCode()); byte[] combined = new byte[epBytes.Length + macBytes.Length];