I am writing a very simple Universal Windows application with VB in Visual Studio 2017.
The application should gave basic network information to the user, so I wanted to collect the data using IPGlobalProperties
and print – as a first example – the DomainName
in a TextBlock called textDomain
Dim NetworkProperties As NetworkInformation.IPGlobalProperties
NetworkProperties = NetworkInformation.IPGlobalProperties.GetIPGlobalProperties
textDomain.Text = NetworkProperties.DomainName
While the properties are correctly assigned int the first two lines of code, the third line result in the error System.PlatformNotSupportedException: 'Operation is not supported on this platform.'
I tried the same code on a classic Windows application and it works as intended, so is this operation not supported by Universal applications?
If yes, what is the method I should use to get the same information about network?
Thanks for any help you might provide
Luca
Firstly,
IPGlobalProperties
class is not supported in uwp app. Since.NET for UWP apps provides a set of managed types that you can use to create Universal Windows Platform apps, but not the all. Details please reference .NET for UWP apps.System.Net
namespace can be used in uwp app butIPGlobalProperties
cannot.Secondly you can find equivalent or similar APIs in uwp app. For example you can also find a
NetworkInformation
in uwp which is belong toWindows.Networking.Connectivity
namespace. But invoking the methods of this class is not the same way with theSystem.Net.NetworkInformation
namespace.If you want to get the computer name or domain name as
IPGlobalProperties
did, you may invoke theGetHostNames()
method. Code as follows: