[corlib] RemotingConfiguration now try to use the bundled machine.config first.
[mono.git] / mcs / class / corlib / System.Runtime.Remoting / RemotingConfiguration.cs
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