Bug 11391 - UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: No such host is known
Summary: UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: No such host is known
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.6.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-03-25 11:06 UTC by Wayne Phipps
Modified: 2013-03-27 07:46 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Wayne Phipps 2013-03-25 11:06:46 UTC
Description of Problem:
Using Xamarin Studio 4.0.3 (build 13) on Windows 7 with Build set to Release:
     "UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: No such host is known"
This only occurs when build is set to Release, Debug runs without error?


Steps to reproduce the problem:
1. Take the following code as example:
	public class Activity1 : Activity
	{

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button> (Resource.Id.myButton);
			
			button.Click += delegate {
				button.Text = IPAddress();
			};
		}

		public string IPAddress()
		{
			string hostName = System.Net.Dns.GetHostName();
			System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostEntry(hostName);
			return hostInfo.AddressList[0].ToString();
		}


2. 
Set Build action to Release and Run

Actual Results:
UNHANDLED EXCEPTION: System.Net.Sockets.SocketException No such host is known

Expected Results:
Runs without error in Debug. Consistent results between Debug and Release

How often does this happen? 
All the time

Additional Information:
Comment 1 Wayne Phipps 2013-03-27 07:46:10 UTC
This was answered and resvolved by Jonathan Prior here: http://forums.xamarin.com/discussion/comment/9064#Comment_9064

Quote:
Your app is missing the INTERNET permission. This is added by default to Debug projects but not Release projects, and is required in order to access network resources.