I am creating a class library that will be used in a WPF project and a .NET Core project. I am trying to get the name of a machine using my application.
In .NET Core and a WPF application, I can use the value of Environment.MachineName . However, in my .NET Standard Class library I cannot.
I get the following error:
"Environment" does not contain a definition for "MachineName"
I tried to do what was suggested in this question , but when I try to add System.Windows.Networking.Connectivity.NetworkInformation.GetHostNames() , I get the following error:
The name "Windows" does not exist in the current context
I assume this only works for Windows 10 Universal Apps? In any case, I would prefer a platform-independent way to get the name of the machine (this method seems to be for window machines only)
source share