[Mono-bugs] [Bug 80203][Wis] New - Bug in System.Dns due to different behavior betwen Mono and .NET

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Dec 9 10:32:45 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by lionel_email at aulofee.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80203

--- shadow/80203	2006-12-09 10:32:45.000000000 -0500
+++ shadow/80203.tmp.11017	2006-12-09 10:32:45.000000000 -0500
@@ -0,0 +1,107 @@
+Bug#: 80203
+Product: Mono: Class Libraries
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: lionel_email at aulofee.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Bug in System.Dns due to different behavior betwen Mono and .NET
+
+Dear All,
+
+When doing a Dns.GetHostName in a new AppDomain (ie a secondary AppDomain),
+ .NET behaves well if I ommit to set the AppDomainSetup.ConfigurationFile
+property.
+
+With Mono (on Ubuntu), I systematically get the quite well-known
+"System.ArgumentException: exePath must be specified when not running
+inside a stand alone exe" (see details and test case below).
+
+I've seen a similar topic discussed on the mono-devel-list (see
+"Assembly.GetEntryAssembly() returns null" at
+http://www.mail-archive.com/mono-devel-list@lists.ximian.com/msg08816.html)
+but I'm not sure it is the same issue.
+
+The solution is to explicitly add something like:
+domainSetup.ConfigurationFile =
+AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
+
+But once more, Mono do behave differently from .Net here, which is
+regrettable...
+
+Cheers,
+
+Lionel
+
+===============
+The test case:
+
+using System;
+using System.Net;
+using System.Reflection;
+
+namespace ConsoleApplication1
+{
+	class Program : MarshalByRefObject
+	{
+		static void Main(string[] args)
+		{
+			AppDomain _secondaryDomain;
+
+			Console.WriteLine("conf file for main domain:");
+		
+Console.WriteLine(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
+
+			AppDomainSetup domainSetup = new AppDomainSetup();
+			domainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
+			domainSetup.ConfigurationFile =
+AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
+			_secondaryDomain = AppDomain.CreateDomain("SecondaryDomain",
+AppDomain.CurrentDomain.Evidence, domainSetup);
+
+			// Creates the SecondDomainHost object in the secondary domain, and
+gives it a reference to the inter-domain object.
+			Program  p = (Program)_secondaryDomain.CreateInstanceAndUnwrap(
+				typeof(Program).Assembly.GetName().Name, typeof(Program).FullName);
+
+			p.Go();
+
+		}
+
+		void Go()
+		{
+			string hostname = Dns.GetHostName();
+			Console.WriteLine(
+				hostname != null ?
+				"hostname is "  + hostname :
+				"hostname is null");
+		}
+	}
+}
+
+==========
+The stack when the exception is thrown:
+
+System.TypeInitializationException: An exception was thrown by the type
+initializer for System.Net.Dns ---> System.ArgumentException: exePath must
+be specified when not running inside a stand alone exe.
+  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal
+(ConfigurationUserLevel userLevel, System.Reflection.Assembly
+calling_assembly, System.String exePath) [0x00000]
+  at
+System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
+(System.String configKey) [0x00000]
+  at System.Configuration.ConfigurationManager.GetSection (System.String
+sectionName) [0x00000]
+  at System.Net.Sockets.Socket.CheckProtocolSupport () [0x00000]
+  at System.Net.Dns..cctor () [0x00000] --- End of inner exception stack
+trace ---


More information about the mono-bugs mailing list