catch NetworkAdapter exceptions if generated
@@ -89,14 +89,14 @@ namespace IoTCoreDefaultApp
}
public static string GetCurrentIpv4Address()
+ {
+ try
{
var icp = NetworkInformation.GetInternetConnectionProfile();
if (icp != null && icp.NetworkAdapter != null && icp.NetworkAdapter.NetworkAdapterId != null)
{
var name = icp.ProfileName;
- try
- {
var hostnames = NetworkInformation.GetHostNames();
foreach (var hn in hostnames)
@@ -111,12 +111,12 @@ namespace IoTCoreDefaultApp
}
}
}
+ }
catch (Exception)
{
// do nothing
// in some (strange) cases NetworkInformation.GetHostNames() fails... maybe a bug in the API...
}
- }
var resourceLoader = ResourceLoader.GetForCurrentView();
var msg = resourceLoader.GetString("NoInternetConnection");
