Merge pull request #297 from ermshiperete/4959
[mono.git] / mcs / class / corlib / System.Runtime.Remoting / RemotingConfiguration.cs
index bce2066513746121da067b8bb9b31d8eddc796df..46e71422e04baf501f3327fe6cfa3d393355a068 100644 (file)
@@ -7,7 +7,31 @@
 // (C) 2002, Jaime Anguiano Olarra
 //
 
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System;
+using System.Globalization;
 using System.IO;
 using System.Reflection;
 using System.Collections;
@@ -18,14 +42,18 @@ using Mono.Xml;
 
 namespace System.Runtime.Remoting
 {      
-       public class RemotingConfiguration
+       [System.Runtime.InteropServices.ComVisible (true)]
+       public static class RemotingConfiguration
        {
+               
                static string applicationID = null;
                static string applicationName = null;
-               static string configFile = "";
-               static MiniParser parser = null; 
+//             static string configFile = "";
+//             static SmallXmlParser parser = null; 
                static string processGuid = null;
                static bool defaultConfigRead = false;
+               static bool defaultDelayedConfigRead = false;
+               static string _errorMode;
 
                static Hashtable wellKnownClientEntries = new Hashtable();
                static Hashtable activatedClientEntries = new Hashtable();
@@ -41,27 +69,25 @@ namespace System.Runtime.Remoting
                public static string ApplicationId 
                {
                        get 
-                       { 
-                               applicationID = AppDomain.CurrentDomain.SetupInformation.ApplicationName; 
+                       {
+                               applicationID = ApplicationName; 
                                return applicationID;
                        }
                }
                
                public static string ApplicationName 
                {
-                       get { 
-                               try {
-                                       applicationName = AppDomain.CurrentDomain.SetupInformation.ApplicationName; 
-                               }
-                               catch (Exception e) {
-                                       throw e;
-                               }
-                               // We return null if the application name has not been set.
-                               return null;
-                       }
+                       get { return applicationName; }
                        set { applicationName = value; }
                }
-               
+
+               [MonoTODO]
+               public static CustomErrorsModes CustomErrorsMode
+               {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
                public static string ProcessId 
                {
                        get {
@@ -75,69 +101,111 @@ namespace System.Runtime.Remoting
 
                // public methods
                
-               public static void Configure (string filename) 
+               [MonoTODO ("ensureSecurity support has not been implemented")]
+               public static void Configure (string filename, bool ensureSecurity) 
                {
-                       if (!defaultConfigRead)
-                       {
-                               ReadConfigFile (Environment.GetMachineConfigPath ());
-                               defaultConfigRead = true;
+                       lock (channelTemplates) {
+                               if (!defaultConfigRead) {
+                                       ReadConfigFile (Environment.GetMachineConfigPath ());
+                                       defaultConfigRead = true;
+                               }
+
+                               if (filename != null)
+                                       ReadConfigFile (filename);
                        }
-                       
-                       if (filename != null)
-                               ReadConfigFile (filename);
+               }
+
+               [Obsolete ("Use Configure(String,Boolean)")]
+               public static void Configure (string filename) 
+               {
+                       Configure (filename, false);
                }
 
                private static void ReadConfigFile (string filename)
                {
                        try
                        {
-                               MiniParser parser = new MiniParser ();
-                               RReader rreader = new RReader (filename);
-                               ConfigHandler handler = new ConfigHandler ();
-                               parser.Parse (rreader, handler);
+                               SmallXmlParser parser = new SmallXmlParser ();
+                               using (TextReader rreader = new StreamReader (filename)) {
+                                       ConfigHandler handler = new ConfigHandler (false);
+                                       parser.Parse (rreader, handler);
+                               }
                        }
                        catch (Exception ex)
                        {
-                               throw new RemotingException ("Configuration file '" + filename + "' could not be loaded: " + ex.Message);
+                               throw new RemotingException ("Configuration file '" + filename + "' could not be loaded: " + ex.Message, ex);
+                       }
+               }
+               
+               internal static void LoadDefaultDelayedChannels ()
+               {
+                       lock (channelTemplates)
+                       {
+                               if (defaultDelayedConfigRead || defaultConfigRead) return;
+                               
+                               SmallXmlParser parser = new SmallXmlParser ();
+                               using (TextReader rreader = new StreamReader (Environment.GetMachineConfigPath ())) {
+                                       ConfigHandler handler = new ConfigHandler (true);
+                                       parser.Parse (rreader, handler);
+                               }
+                               defaultDelayedConfigRead = true;
                        }
                }
        
-               private static ActivatedClientTypeEntry[] GetRegisteredActivatedClientTypes () 
+               public static ActivatedClientTypeEntry[] GetRegisteredActivatedClientTypes () 
                {
-                       ActivatedClientTypeEntry[] entries = new ActivatedClientTypeEntry[activatedClientEntries.Count];
-                       activatedClientEntries.Values.CopyTo (entries,0);
-                       return entries;
+                       lock (channelTemplates)
+                       {
+                               ActivatedClientTypeEntry[] entries = new ActivatedClientTypeEntry[activatedClientEntries.Count];
+                               activatedClientEntries.Values.CopyTo (entries,0);
+                               return entries;
+                       }
                }
 
                public static ActivatedServiceTypeEntry[] GetRegisteredActivatedServiceTypes () 
                {
-                       ActivatedServiceTypeEntry[] entries = new ActivatedServiceTypeEntry[activatedServiceEntries.Count];
-                       activatedServiceEntries.Values.CopyTo (entries,0);
-                       return entries;
+                       lock (channelTemplates)
+                       {
+                               ActivatedServiceTypeEntry[] entries = new ActivatedServiceTypeEntry[activatedServiceEntries.Count];
+                               activatedServiceEntries.Values.CopyTo (entries,0);
+                               return entries;
+                       }
                }
 
                public static WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes () 
                {
-                       WellKnownClientTypeEntry[] entries = new WellKnownClientTypeEntry[wellKnownClientEntries.Count];
-                       wellKnownClientEntries.Values.CopyTo (entries,0);
-                       return entries;
+                       lock (channelTemplates)
+                       {
+                               WellKnownClientTypeEntry[] entries = new WellKnownClientTypeEntry[wellKnownClientEntries.Count];
+                               wellKnownClientEntries.Values.CopyTo (entries,0);
+                               return entries;
+                       }
                }
 
                public static WellKnownServiceTypeEntry[] GetRegisteredWellKnownServiceTypes () 
                {
-                       WellKnownServiceTypeEntry[] entries = new WellKnownServiceTypeEntry[wellKnownServiceEntries.Count];
-                       wellKnownServiceEntries.Values.CopyTo (entries,0);
-                       return entries;
+                       lock (channelTemplates)
+                       {
+                               WellKnownServiceTypeEntry[] entries = new WellKnownServiceTypeEntry[wellKnownServiceEntries.Count];
+                               wellKnownServiceEntries.Values.CopyTo (entries,0);
+                               return entries;
+                       }
                }
 
-               public static bool IsActivationAllowed (Type serverType) 
+               public static bool IsActivationAllowed (Type svrType) 
                {
-                       return activatedServiceEntries.ContainsKey (serverType);
+                       lock (channelTemplates)
+                       {
+                               return activatedServiceEntries.ContainsKey (svrType);
+                       }
                }
 
-               public static ActivatedClientTypeEntry IsRemotelyActivatedClientType (Type serviceType) 
+               public static ActivatedClientTypeEntry IsRemotelyActivatedClientType (Type svrType) 
                {
-                       return activatedClientEntries [serviceType] as ActivatedClientTypeEntry;
+                       lock (channelTemplates)
+                       {
+                               return activatedClientEntries [svrType] as ActivatedClientTypeEntry;
+                       }
                }
 
                public static ActivatedClientTypeEntry IsRemotelyActivatedClientType (string typeName, string assemblyName) 
@@ -145,9 +213,12 @@ namespace System.Runtime.Remoting
                        return IsRemotelyActivatedClientType (Assembly.Load(assemblyName).GetType (typeName));
                }
 
-               public static WellKnownClientTypeEntry IsWellKnownClientType (Type serviceType) 
+               public static WellKnownClientTypeEntry IsWellKnownClientType (Type svrType) 
                {
-                       return wellKnownClientEntries [serviceType] as WellKnownClientTypeEntry;
+                       lock (channelTemplates)
+                       {
+                               return wellKnownClientEntries [svrType] as WellKnownClientTypeEntry;
+                       }
                }
 
                public static WellKnownClientTypeEntry IsWellKnownClientType (string typeName, string assemblyName) 
@@ -157,11 +228,14 @@ namespace System.Runtime.Remoting
 
                public static void RegisterActivatedClientType (ActivatedClientTypeEntry entry) 
                {
-                       if (wellKnownClientEntries.ContainsKey (entry.ObjectType) || activatedClientEntries.ContainsKey (entry.ObjectType))
-                               throw new RemotingException ("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected.");
-
-                       activatedClientEntries[entry.ObjectType] = entry;
-                       ActivationServices.EnableProxyActivation (entry.ObjectType, true);
+                       lock (channelTemplates)
+                       {
+                               if (wellKnownClientEntries.ContainsKey (entry.ObjectType) || activatedClientEntries.ContainsKey (entry.ObjectType))
+                                       throw new RemotingException ("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected.");
+       
+                               activatedClientEntries[entry.ObjectType] = entry;
+                               ActivationServices.EnableProxyActivation (entry.ObjectType, true);
+                       }
                }
 
                public static void RegisterActivatedClientType (Type type, string appUrl) 
@@ -174,7 +248,10 @@ namespace System.Runtime.Remoting
 
                public static void RegisterActivatedServiceType (ActivatedServiceTypeEntry entry) 
                {
-                       activatedServiceEntries.Add (entry.ObjectType, entry);
+                       lock (channelTemplates)
+                       {
+                               activatedServiceEntries.Add (entry.ObjectType, entry);
+                       }
                }
 
                public static void RegisterActivatedServiceType (Type type) 
@@ -192,22 +269,28 @@ namespace System.Runtime.Remoting
 
                public static void RegisterWellKnownClientType (WellKnownClientTypeEntry entry) 
                {
-                       if (wellKnownClientEntries.ContainsKey (entry.ObjectType) || activatedClientEntries.ContainsKey (entry.ObjectType))
-                               throw new RemotingException ("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected.");
-
-                       wellKnownClientEntries[entry.ObjectType] = entry;
-                       ActivationServices.EnableProxyActivation (entry.ObjectType, true);
+                       lock (channelTemplates)
+                       {
+                               if (wellKnownClientEntries.ContainsKey (entry.ObjectType) || activatedClientEntries.ContainsKey (entry.ObjectType))
+                                       throw new RemotingException ("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected.");
+       
+                               wellKnownClientEntries[entry.ObjectType] = entry;
+                               ActivationServices.EnableProxyActivation (entry.ObjectType, true);
+                       }
                }
 
-               public static void RegisterWellKnownServiceType (Type type, string objectUrl, WellKnownObjectMode mode) 
+               public static void RegisterWellKnownServiceType (Type type, string objectUri, WellKnownObjectMode mode) 
                {
-                       RegisterWellKnownServiceType (new WellKnownServiceTypeEntry (type, objectUrl, mode));
+                       RegisterWellKnownServiceType (new WellKnownServiceTypeEntry (type, objectUri, mode));
                }
 
                public static void RegisterWellKnownServiceType (WellKnownServiceTypeEntry entry) 
                {
-                       wellKnownServiceEntries [entry.ObjectUri] = entry;
-                       RemotingServices.CreateWellKnownServerIdentity (entry.ObjectType, entry.ObjectUri, entry.Mode);
+                       lock (channelTemplates)
+                       {
+                               wellKnownServiceEntries [entry.ObjectUri] = entry;
+                               RemotingServices.CreateWellKnownServerIdentity (entry.ObjectType, entry.ObjectUri, entry.Mode);
+                       }
                }
 
                internal static void RegisterChannelTemplate (ChannelData channel)
@@ -225,10 +308,16 @@ namespace System.Runtime.Remoting
                        serverProviderTemplates [prov.Id] = prov;
                }
                
-               internal static void RegisterChannels (ArrayList channels)
+               internal static void RegisterChannels (ArrayList channels, bool onlyDelayed)
                {
                        foreach (ChannelData channel in channels)
                        {
+                               if (onlyDelayed && channel.DelayLoadAsClientChannel != "true")
+                                       continue;
+                                       
+                               if (defaultDelayedConfigRead && channel.DelayLoadAsClientChannel == "true")
+                                       continue;
+                                       
                                if (channel.Ref != null)
                                {
                                        ChannelData template = (ChannelData) channelTemplates [channel.Ref];
@@ -274,39 +363,36 @@ namespace System.Runtime.Remoting
                                        RegisterWellKnownServiceType ((WellKnownServiceTypeEntry)type);
                        }
                }
+               
+#if NET_1_1
+               public static bool CustomErrorsEnabled (bool isLocalRequest)
+               {
+                       if (_errorMode == "off") return false;
+                       if (_errorMode == "on") return true;
+                       return !isLocalRequest;
+               }
+#endif
+
+               internal static void SetCustomErrorsMode (string mode)
+               {
+                       if (mode == null)
+                               throw new RemotingException ("mode attribute is required");
+
+                       // the mode is case insensitive
+                       string m = mode.ToLower ();
+
+                       if (m != "on" && m != "off" && m != "remoteonly")
+                               throw new RemotingException ("Invalid custom error mode: " + mode);
+                               
+                       _errorMode = m;
+               }
        }
 
        /***************************************************************
         * Internal classes used by RemotingConfiguration.Configure () *
         ***************************************************************/
         
-       internal class RReader : MiniParser.IReader {
-               private string xml; // custom remoting config file
-               private int pos;
-
-               public RReader (string filename)
-               {
-                       try {
-                               StreamReader sr = new StreamReader (filename);
-                               xml = sr.ReadToEnd ();
-                               sr.Close ();
-                       }
-                       catch {
-                               xml = null;
-                       }
-               }
-
-               public int Read () {
-                       try {
-                               return (int) xml[pos++];
-                       }
-                       catch {
-                               return -1;
-                       }
-               }
-       }
-       
-       internal class ConfigHandler : MiniParser.IHandler 
+       internal class ConfigHandler : SmallXmlParser.IContentHandler 
        {
                ArrayList typeEntries = new ArrayList ();
                ArrayList channelInstances = new ArrayList ();
@@ -318,9 +404,11 @@ namespace System.Runtime.Remoting
                string appName;
                
                string currentXmlPath = "";
+               bool onlyDelayedChannels;
                
-               public ConfigHandler ()
+               public ConfigHandler (bool onlyDelayedChannels)
                {
+                       this.onlyDelayedChannels = onlyDelayedChannels;
                }
                
                void ValidatePath (string element, params string[] paths)
@@ -333,15 +421,20 @@ namespace System.Runtime.Remoting
                
                bool CheckPath (string path)
                {
-                       if (path.StartsWith ("/"))
+                       CompareInfo ci = CultureInfo.InvariantCulture.CompareInfo;
+                       if (ci.IsPrefix (path, "/", CompareOptions.Ordinal))
                                return path == currentXmlPath;
                        else
-                               return currentXmlPath.EndsWith (path);
+                               return ci.IsSuffix (currentXmlPath, path, CompareOptions.Ordinal);
                }
                
-               public void OnStartParsing (MiniParser parser) {}
+               public void OnStartParsing (SmallXmlParser parser) {}
                
-               public void OnStartElement (string name, MiniParser.IAttrList attrs)
+               public void OnProcessingInstruction (string name, string text) {}
+
+               public void OnIgnorableWhitespace (string s) {}
+
+               public void OnStartElement (string name, SmallXmlParser.IAttrList attrs)
                {
                        try
                        {
@@ -352,11 +445,11 @@ namespace System.Runtime.Remoting
                        }
                        catch (Exception ex)
                        {
-                               throw new RemotingException ("Error in element " + name + ": " + ex.Message);
+                               throw new RemotingException ("Error in element " + name + ": " + ex.Message, ex);
                        }
                }
                
-               public void ParseElement (string name, MiniParser.IAttrList attrs)
+               public void ParseElement (string name, SmallXmlParser.IAttrList attrs)
                {
                        if (currentProviderData != null)
                        {
@@ -458,14 +551,17 @@ namespace System.Runtime.Remoting
                                        
                                case "interopXmlType":
                                        ValidatePath (name, "soapInterop");
+                                       ReadInteropXml (attrs, false);
                                        break;
                                        
                                case "interopXmlElement":
                                        ValidatePath (name, "soapInterop");
+                                       ReadInteropXml (attrs, false);
                                        break;
                                        
                                case "preLoad":
                                        ValidatePath (name, "soapInterop");
+                                       ReadPreload (attrs);
                                        break;
                                        
                                case "debug":
@@ -476,6 +572,11 @@ namespace System.Runtime.Remoting
                                        ValidatePath (name, "system.runtime.remoting");
                                        break;
                                        
+                               case "customErrors":
+                                       ValidatePath (name, "system.runtime.remoting");
+                                       RemotingConfiguration.SetCustomErrorsMode (attrs.GetValue ("mode"));
+                                       break;
+                                       
                                default:
                                        throw new RemotingException ("Element '" + name + "' is not valid in system.remoting.configuration section");
                        }
@@ -486,14 +587,14 @@ namespace System.Runtime.Remoting
                        if (currentProviderData != null)
                        {
                                currentProviderData.Pop ();
-                               if (currentProviderData.Count > 0) return;
-                               currentProviderData = null;
+                               if (currentProviderData.Count == 0) 
+                                       currentProviderData = null;
                        }
                        
                        currentXmlPath = currentXmlPath.Substring (0, currentXmlPath.Length - name.Length - 1);
                }
                
-               void ReadCustomProviderData (string name, MiniParser.IAttrList attrs)
+               void ReadCustomProviderData (string name, SmallXmlParser.IAttrList attrs)
                {
                        SinkProviderData parent = (SinkProviderData) currentProviderData.Peek ();
                        
@@ -505,14 +606,14 @@ namespace System.Runtime.Remoting
                        currentProviderData.Push (data);
                }
 
-               void ReadLifetine (MiniParser.IAttrList attrs)
+               void ReadLifetine (SmallXmlParser.IAttrList attrs)
                {
                        for (int i=0; i < attrs.Names.Length; ++i) {
                                switch (attrs.Names[i]) {
                                case "leaseTime":
                                        LifetimeServices.LeaseTime = ParseTime (attrs.GetValue(i));
                                        break;
-                               case "sponsorShipTimeOut":
+                               case "sponsorshipTimeout":
                                        LifetimeServices.SponsorshipTimeout = ParseTime (attrs.GetValue(i));
                                        break;
                                case "renewOnCallTime":
@@ -557,7 +658,7 @@ namespace System.Runtime.Remoting
                        throw new RemotingException ("Invalid time unit: " + unit);
                }
                
-               void ReadChannel (MiniParser.IAttrList attrs, bool isTemplate)
+               void ReadChannel (SmallXmlParser.IAttrList attrs, bool isTemplate)
                {
                        ChannelData channel = new ChannelData ();
                        
@@ -590,7 +691,7 @@ namespace System.Runtime.Remoting
                        currentChannel = channel;
                }
                
-               ProviderData ReadProvider (string name, MiniParser.IAttrList attrs, bool isTemplate)
+               ProviderData ReadProvider (string name, SmallXmlParser.IAttrList attrs, bool isTemplate)
                {
                        ProviderData prov = (name == "provider") ? new ProviderData () : new FormatterData ();
                        SinkProviderData data = new SinkProviderData ("root");
@@ -606,9 +707,9 @@ namespace System.Runtime.Remoting
                                
                                if (at == "id" && isTemplate)
                                        prov.Id = val;
-                               if (at == "type")
+                               else if (at == "type")
                                        prov.Type = val;
-                               if (at == "ref" && !isTemplate)
+                               else if (at == "ref" && !isTemplate)
                                        prov.Ref = val;
                                else
                                        prov.CustomProperties.Add (at, val);
@@ -618,7 +719,7 @@ namespace System.Runtime.Remoting
                        return prov;
                }
                
-               void ReadClientActivated (MiniParser.IAttrList attrs)
+               void ReadClientActivated (SmallXmlParser.IAttrList attrs)
                {
                        string type = GetNotNull (attrs, "type");
                        string assm = ExtractAssembly (ref type);
@@ -629,7 +730,7 @@ namespace System.Runtime.Remoting
                        typeEntries.Add (new ActivatedClientTypeEntry (type, assm, currentClientUrl));
                }
                
-               void ReadServiceActivated (MiniParser.IAttrList attrs)
+               void ReadServiceActivated (SmallXmlParser.IAttrList attrs)
                {
                        string type = GetNotNull (attrs, "type");
                        string assm = ExtractAssembly (ref type);
@@ -637,7 +738,7 @@ namespace System.Runtime.Remoting
                        typeEntries.Add (new ActivatedServiceTypeEntry (type, assm));
                }
                
-               void ReadClientWellKnown (MiniParser.IAttrList attrs)
+               void ReadClientWellKnown (SmallXmlParser.IAttrList attrs)
                {
                        string url = GetNotNull (attrs, "url");
                        string type = GetNotNull (attrs, "type");
@@ -646,7 +747,7 @@ namespace System.Runtime.Remoting
                        typeEntries.Add (new WellKnownClientTypeEntry (type, assm, url));
                }
                
-               void ReadServiceWellKnown (MiniParser.IAttrList attrs)
+               void ReadServiceWellKnown (SmallXmlParser.IAttrList attrs)
                {
                        string objectUri = GetNotNull (attrs, "objectUri");
                        string smode = GetNotNull (attrs, "mode");
@@ -661,7 +762,34 @@ namespace System.Runtime.Remoting
                        typeEntries.Add (new WellKnownServiceTypeEntry (type, assm, objectUri, mode));
                }
                
-               string GetNotNull (MiniParser.IAttrList attrs, string name)
+               void ReadInteropXml (SmallXmlParser.IAttrList attrs, bool isElement)
+               {
+                       Type t = Type.GetType (GetNotNull (attrs, "clr"));
+                       string[] xmlName = GetNotNull (attrs, "xml").Split (',');
+                       string localName = xmlName [0].Trim ();
+                       string ns = xmlName.Length > 0 ? xmlName[1].Trim() : null;
+                       
+                       if (isElement) SoapServices.RegisterInteropXmlElement (localName, ns, t);
+                       else SoapServices.RegisterInteropXmlType (localName, ns, t);
+               }
+               
+               void ReadPreload (SmallXmlParser.IAttrList attrs)
+               {
+                       string type = attrs.GetValue ("type");
+                       string assm = attrs.GetValue ("assembly");
+                       
+                       if (type != null && assm != null)
+                               throw new RemotingException ("Type and assembly attributes cannot be specified together");
+                               
+                       if (type != null)
+                               SoapServices.PreLoad (Type.GetType (type));
+                       else if (assm != null)
+                               SoapServices.PreLoad (Assembly.Load (assm));
+                       else
+                               throw new RemotingException ("Either type or assembly attributes must be specified");
+               }
+                                       
+               string GetNotNull (SmallXmlParser.IAttrList attrs, string name)
                {
                        string value = attrs.GetValue (name);
                        if (value == null || value == "") 
@@ -671,7 +799,7 @@ namespace System.Runtime.Remoting
                
                string ExtractAssembly (ref string type)
                {
-                       int i = type.IndexOf (",");
+                       int i = type.IndexOf (',');
                        if (i == -1) return "";
                        
                        string asm = type.Substring (i+1).Trim();
@@ -681,10 +809,13 @@ namespace System.Runtime.Remoting
                
                public void OnChars (string ch) {}
                
-               public void OnEndParsing (MiniParser parser)
+               public void OnEndParsing (SmallXmlParser parser)
                {
-                       RemotingConfiguration.RegisterChannels (channelInstances);
-                       RemotingConfiguration.RegisterTypes (typeEntries);
+                       RemotingConfiguration.RegisterChannels (channelInstances, onlyDelayedChannels);
+                       if (appName != null) RemotingConfiguration.ApplicationName = appName;
+                       
+                       if (!onlyDelayedChannels)
+                               RemotingConfiguration.RegisterTypes (typeEntries);
                }
        }