I am making a windows phone 7 application in c#, visual studio 2012 and it needs to check if internet connection is available in the device before sending some request.
Initially I was trying to use
NetworkInterface.GetIsNetworkAvailable()
but it always returned true.I found a solution here. But I am now having problem with that also.
I wrote the following code(after using System.Net
)
Code
private bool checkInternet()
{
try
{
IPHostEntry _hostEntry = Dns.GetHostEntry("www.google.com");
return true;
}
catch(SocketException _err){
return false;
}
}
But it didn't compile and gave the following error Error_Image
Error 1 The type or namespace name 'IPHostEntry' could not be found (are you missing a using directive or an assembly reference?)