2008-07-09 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Wed, 9 Jul 2008 17:20:29 +0000 (17:20 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 9 Jul 2008 17:20:29 +0000 (17:20 -0000)
* ConfigurationManager.cs: implemented a work-around for
OpenExeConfiguration ("") not working with ASP.NET apps properly.

svn path=/trunk/mcs/; revision=107569

mcs/class/System.Configuration/System.Configuration/ChangeLog
mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs

index 6839c577aa20ff18f94b1261cee7712b0d60911d..032a9fa41007f3ea27765d92153f3150a117c560 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-09  Marek Habersack  <mhabersack@novell.com>
+
+       * ConfigurationManager.cs: implemented a work-around for
+       OpenExeConfiguration ("") not working with ASP.NET apps properly.
+
 2008-07-07  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * ConfigurationManager.cs: Return the right path if the calling assembly is
index bf25c33000b5d4cf31e96c849efe615245f0011f..0a2b895c28249b603f09751b30eca2d5d69de335 100644 (file)
@@ -43,10 +43,11 @@ namespace System.Configuration {
 
        public static class ConfigurationManager
        {
+               static bool systemWebInUse;
                static InternalConfigurationFactory configFactory = new InternalConfigurationFactory ();
                static IInternalConfigSystem configSystem = new ClientConfigurationSystem ();
                static object lockobj = new object ();
-
+               
                [MonoTODO ("Evidence and version still needs work")]
                static string GetAssemblyInfo (Assembly a)
                {
@@ -93,7 +94,7 @@ namespace System.Configuration {
                        switch (userLevel) {
                        case ConfigurationUserLevel.None:
                                if (exePath == null || exePath.Length == 0) {
-                                       if (calling_assembly != null)
+                                       if (!systemWebInUse && calling_assembly != null)
                                                exePath = calling_assembly.Location;
                                        else
                                                exePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
@@ -195,6 +196,15 @@ namespace System.Configuration {
                                throw new ArgumentNullException ("newSystem");
 
                        lock (lockobj) {
+                               // KLUDGE!! We need that when an assembly loaded inside an ASP.NET
+                               // domain does OpenExeConfiguration ("") - we must return the path
+                               // to web.config in that instance.
+                               string t = newSystem.GetType ().ToString ();
+                               if (String.Compare (t, "System.Web.Configuration.HttpConfigurationSystem", StringComparison.OrdinalIgnoreCase) == 0)
+                                       systemWebInUse = true;
+                               else
+                                       systemWebInUse = false;
+
                                IInternalConfigSystem old = configSystem;
                                configSystem = newSystem;
                                return old;