Dim _isNetworkAvailable = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsWiFiEnabled

always returns false though I do have internet connection.
I'm testing on the emulator, could that be the source of the issue?

How I'm testing: I have a button that calls the above code and displays the result of the boolean in a textbox

有帮助吗?

解决方案

Your current code only check whether Wifi enabled or not on the device, which will always return false if you run in emulator. Because there is no interface to set Wifi enabled in WP7 emulator. You need to use IsNetworkAvailable property instead, to check if any internet connection available. See this MSDN link for reference. So your code should be as follow :

Dim _isNetworkAvailable = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top