Sequence contains no elements when internet is disabled
VladislavAntonyuk opened this issue · comments
at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at Plugin.DeviceInfo.DeviceInfoImplementation..ctor() in D:\a\1\s\src\DeviceInfo.Plugin\DeviceInfo.desktop.cs:line 22 at Plugin.DeviceInfo.CrossDeviceInfo.<>c.<.cctor>b__8_0() in D:\a\1\s\src\DeviceInfo.Plugin\CrossDeviceInfo.shared.cs:line 11 at System.Lazy
1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Plugin.DeviceInfo.CrossDeviceInfo.get_Current() in D:\a\1\s\src\DeviceInfo.Plugin\CrossDeviceInfo.shared.cs:line 25
Version 4.1.1
Platfrom Windows, .net 4.7.2
public string Id { get; } = NetworkInterface
.GetAllNetworkInterfaces()
.Where(nic =>
nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||
nic.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
.Select(nic => nic.GetPhysicalAddress().ToString())
.First();
I think it would be better to get device id or product id, or just change with FirstOrDefault
Put in FirstOrDefault however, i don't love this implementation. I didn't do it originally.