Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Sequence contains no elements when internet is disabled #71

Closed
VladislavAntonyuk opened this issue Mar 3, 2019 · 2 comments
Closed

Comments

@VladislavAntonyuk
Copy link

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.Lazy1.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

@VladislavAntonyuk VladislavAntonyuk changed the title Sequence contains no elements Sequence contains no elements when internet is disabled Mar 3, 2019
@VladislavAntonyuk
Copy link
Author

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

@jamesmontemagno
Copy link
Owner

Put in FirstOrDefault however, i don't love this implementation. I didn't do it originally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants