[corlib] RemotingConfiguration now try to use the bundled machine.config first.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 6 Oct 2016 22:04:48 +0000 (15:04 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 6 Oct 2016 22:04:48 +0000 (15:04 -0700)
mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
mcs/class/corlib/System/Environment.cs
mono/metadata/icall-def.h

index b553070deaa7350cd357deb13fd2dae51e5805c4..eb45ced8220104fedb88ee88eb5f57c6af55be7f 100644 (file)
@@ -106,6 +106,10 @@ namespace System.Runtime.Remoting
                {
                        lock (channelTemplates) {
                                if (!defaultConfigRead) {
+                                       var bundled = Environment.GetBundledMachineConfig ();
+                                       if (bundled != null)
+                                               ReadConfigString (bundled);
+
                                        if (File.Exists (Environment.GetMachineConfigPath ()))
                                                ReadConfigFile (Environment.GetMachineConfigPath ());
                                        defaultConfigRead = true;
@@ -122,6 +126,22 @@ namespace System.Runtime.Remoting
                        Configure (filename, false);
                }
 
+               private static void ReadConfigString (string filename)
+               {
+                       try
+                       {
+                               SmallXmlParser parser = new SmallXmlParser ();
+                               using (TextReader rreader = new StringReader (filename)) {
+                                       ConfigHandler handler = new ConfigHandler (false);
+                                       parser.Parse (rreader, handler);
+                               }
+                       }
+                       catch (Exception ex)
+                       {
+                               throw new RemotingException ("Configuration string could not be loaded: " + ex.Message, ex);
+                       }
+               }
+
                private static void ReadConfigFile (string filename)
                {
                        try
index 22b4ef6748ccc18659e36beff266127d8ce5c58f..df80c8348a6bd2cee43cebe596f88767fbb2749f 100644 (file)
@@ -996,6 +996,14 @@ namespace System {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal extern static int GetPageSize ();
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern private static string get_bundled_machine_config ();
+
+               internal static string GetBundledMachineConfig ()
+               {
+                       return get_bundled_machine_config ();
+               }
+
                static internal bool IsUnix {
                        get {
                                int platform = (int) Environment.Platform;
index 703ad861363ca259bc48ebf4e7a298d0595d9fc5..5a4751a6a38e2c56ab9cacd0033d316bc38f48f6 100644 (file)
@@ -521,6 +521,7 @@ ICALL(ENV_13, "get_Platform", ves_icall_System_Environment_get_Platform)
 ICALL(ENV_14, "get_ProcessorCount", mono_cpu_count)
 ICALL(ENV_15, "get_TickCount", ves_icall_System_Environment_get_TickCount)
 ICALL(ENV_16, "get_UserName", ves_icall_System_Environment_get_UserName)
+HANDLES(ICALL(ENV_16b, "get_bundled_machine_config", get_bundled_machine_config))
 ICALL(ENV_16m, "internalBroadcastSettingChange", ves_icall_System_Environment_BroadcastSettingChange)
 HANDLES(ICALL(ENV_17, "internalGetEnvironmentVariable_native", ves_icall_System_Environment_GetEnvironmentVariable_native))
 HANDLES(ICALL(ENV_18, "internalGetGacPath", ves_icall_System_Environment_GetGacPath))