2007-08-23 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Thu, 23 Aug 2007 10:30:37 +0000 (10:30 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Thu, 23 Aug 2007 10:30:37 +0000 (10:30 -0000)
            * ProvidersHelper.cs: HttpApplication.LoadTypeFromPrivateBin
            renamed to LoadTypeFromBin.

2007-08-23  Marek Habersack  <mhabersack@novell.com>

            * AppCodeCompiler.cs: use HttpApplication.BinDirectoryAssemblies
            and HttpApplication.LoadTypeFromBin.

            * BuildProvider.cs: use HttpApplication.BinDirectoryAssemblies in
            AddAssembliesInBin.

2007-08-23  Marek Habersack  <mhabersack@novell.com>

            * ApplicationHost.cs: set AppDomainSetup.PrivateBinPath to "bin"
            if running on Windows or with MONO_IOMAP in effect, and to
            "Bin:bin" otherwise.

2007-08-23  Marek Habersack  <mhabersack@novell.com>

            * SimpleWebHandlerParser.cs: use
            HttpApplication.BinDirectoryAssemblies in AddAssembliesInBin and
            LoadAssemblyFromBin.
            Restore the old logic in GetTypeFromBin, also use
            HttpApplication.BinDirectoryAssemblies there.

            * TemplateParser.cs: use HttpApplication.BinDirectories to
            interate over the list of bin dirs.
            Use HttpApplication.BinDirectoryAssemblies in AddAssembliesInBin.

2007-08-23  Marek Habersack  <mhabersack@novell.com>

            * HttpApplication.cs: added a static array BinDirs which contains
            the common bin directory names we can encounter.
            Added internal static property IsRunningOnWindows.
            Added internal enumerable property BinDirectories to iterate over
            the full paths of the available binary directories.
            Added internal enumerable property BinDirectoryAssemblies to
            iterate over .dll files in the bin directories.
            LoadTypeFromPrivateBin renamed to LoadTypeFromBin.
            LoadTypeFromBin uses BinDirectoryAssemblies.

            * HttpApplicationFactory.cs: use HttpApplication.BinDirectories to
            interate over the list of bin dirs.

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

13 files changed:
mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
mcs/class/System.Web/System.Web.Compilation/BuildProvider.cs
mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
mcs/class/System.Web/System.Web.Configuration_2.0/ProvidersHelper.cs
mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs
mcs/class/System.Web/System.Web.Hosting/ChangeLog
mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs
mcs/class/System.Web/System.Web.UI/TemplateParser.cs
mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpApplication.cs
mcs/class/System.Web/System.Web/HttpApplicationFactory.cs

index 5a0f7c7a3b9c4a01221d43c893a5affdf695ae09..283eebe98d3b85ed0e602b9d1350667b675094b3 100644 (file)
@@ -639,18 +639,7 @@ namespace System.Web.Compilation
                                return;
 
                        HttpRuntime.EnableAssemblyMapping (true);
-                       ArrayList binAssembliesAl = null;
-                       string[] binAssemblies = null;
-                       
-                       foreach (string bindir in HttpApplication.PrivateBinPath) {
-                               if (!Directory.Exists (bindir))
-                                       continue;
-                               if (binAssemblies == null)
-                                       binAssembliesAl = new ArrayList ();
-                               binAssembliesAl.AddRange (Directory.GetFiles (bindir, "*.dll"));
-                       }
-                       if (binAssembliesAl != null)
-                               binAssemblies = (string[])binAssembliesAl.ToArray (typeof (string));
+                       string[] binAssemblies = HttpApplication.BinDirectoryAssemblies;
                        
                        foreach (AppCodeAssembly aca in assemblies)
                                aca.Build (binAssemblies);
@@ -669,7 +658,7 @@ namespace System.Web.Compilation
                                } else
                                        return;
 
-                               if (HttpApplication.LoadTypeFromPrivateBin (providerTypeName) == null)
+                               if (HttpApplication.LoadTypeFromBin (providerTypeName) == null)
                                        throw new HttpException (String.Format ("Profile provider type not found: {0}",
                                                                                providerTypeName));
                        }
index 36c6c901750514e2711000d4b610fe3847d8df20..25d3a42802cfa9b719309c67cda3c2e05f6a3df7 100644 (file)
@@ -93,15 +93,9 @@ namespace System.Web.Compilation {
 
                void AddAssembliesInBin (StringCollection coll)
                {
-                       foreach (string private_bin_path in HttpApplication.PrivateBinPath) {
-                               if (!Directory.Exists (private_bin_path))
-                                       continue;
-
-                               string [] binDlls = Directory.GetFiles (private_bin_path, "*.dll");
-                               foreach (string s in binDlls) {
-                                       coll.Add (s);
-                                       ref_assemblies.Add (s);
-                               }
+                       foreach (string s in HttpApplication.BinDirectoryAssemblies) {
+                               coll.Add (s);
+                               ref_assemblies.Add (s);
                        }
                }
 
index 719d2511f84755c79d3feb6125ee39c44c720e1b..9c508cc1a8f849abc76beb0a816df011e0e54e81 100644 (file)
@@ -1,3 +1,11 @@
+2007-08-23  Marek Habersack  <mhabersack@novell.com>
+
+       * AppCodeCompiler.cs: use HttpApplication.BinDirectoryAssemblies
+       and HttpApplication.LoadTypeFromBin.
+
+       * BuildProvider.cs: use HttpApplication.BinDirectoryAssemblies in
+       AddAssembliesInBin.
+
 2007-08-21  Marek Habersack  <mhabersack@novell.com>
 
        * BuildProvider.cs: use HttpApplication.PrivateBinPath enumerator
index b6d58cead39a48a3a765dc88449221b1409d81bb..169d3d6dea9836eb8b0c8284450bcfd35587e37a 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-23  Marek Habersack  <mhabersack@novell.com>
+
+       * ProvidersHelper.cs: HttpApplication.LoadTypeFromPrivateBin
+       renamed to LoadTypeFromBin.
+
 2007-08-21  Marek Habersack  <mhabersack@novell.com>
 
        * ProvidersHelper.cs: use HttpApplication.LoadTypeFromPrivateBin
index b410f5da9bf0b42343681e05f0236b46723d57e3..c15715b29ac40b03f7d810f8111b8c0b0572cadc 100644 (file)
@@ -49,7 +49,7 @@ namespace System.Web.Configuration {
                        Type settingsType = Type.GetType (providerSettings.Type);
                        
                        if (settingsType == null)
-                               settingsType = HttpApplication.LoadTypeFromPrivateBin (providerSettings.Type);
+                               settingsType = HttpApplication.LoadTypeFromBin (providerSettings.Type);
 
                        // check App_Code dlls
                        if (settingsType == null) {
index 457cf1e23d9ee1517f1a7aed253e673417d7a027..51e30ff5c02684616c0d04159065fad4f2eb381a 100644 (file)
@@ -35,8 +35,7 @@ namespace System.Web.Hosting {
 
        // CAS - no InheritanceDemand here as the class is sealed
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
-       public sealed class ApplicationHost {
-
+       public sealed class ApplicationHost {           
                static string [] types = { "Web.config", "Web.Config", "web.config" };
 
                private ApplicationHost ()
@@ -155,11 +154,10 @@ namespace System.Web.Hosting {
                        setup.ConfigurationFile = FindWebConfig (physicalDir);
                        setup.DisallowCodeDownload = true;
 
-                       //
-                       // We use Path.PathSeparator even though MSDN says semicolons are used. Our
-                       // runtime expects a Path.PathSeparator.
-                       //
-                       setup.PrivateBinPath = String.Format ("Bin{0}bin", Path.PathSeparator);
+                       if (Environment.GetEnvironmentVariable ("MONO_IOMAP") != null || HttpApplication.IsRunningOnWindows)
+                               setup.PrivateBinPath = "bin";
+                       else
+                               setup.PrivateBinPath = String.Join (Path.PathSeparator.ToString (), HttpApplication.BinDirs);
                        setup.PrivateBinPathProbe = "*";
                        setup.ShadowCopyFiles = "true";
                        setup.ShadowCopyDirectories = setup.PrivateBinPath;
index b2c1703039d025a511a064364c8d98cac84d7dc0..9e53ee1cd313866b15353a0a83867638bff2ee60 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-23  Marek Habersack  <mhabersack@novell.com>
+
+       * ApplicationHost.cs: set AppDomainSetup.PrivateBinPath to "bin"
+       if running on Windows or with MONO_IOMAP in effect, and to
+       "Bin:bin" otherwise.
+
 2007-08-21  Marek Habersack  <mhabersack@novell.com>
 
        * ApplicationHost.cs: AppDomainSetup.PrivateBinPath should contain
index 4224ad5fd3db5579b8dbb618a31593e918e2a3bf..979fac0f68ff51e446d922648059a02371fad4f8 100644 (file)
@@ -1,3 +1,15 @@
+2007-08-23  Marek Habersack  <mhabersack@novell.com>
+
+       * SimpleWebHandlerParser.cs: use
+       HttpApplication.BinDirectoryAssemblies in AddAssembliesInBin and
+       LoadAssemblyFromBin.
+       Restore the old logic in GetTypeFromBin, also use
+       HttpApplication.BinDirectoryAssemblies there.
+
+       * TemplateParser.cs: use HttpApplication.BinDirectories to
+       interate over the list of bin dirs.
+       Use HttpApplication.BinDirectoryAssemblies in AddAssembliesInBin.
+
 2007-08-23 Igor Zelmanovich <igorz@mainsoft.com>
 
        * ClientScriptManager.cs: encode values of hidden fields. 
index 783cf55131288f32253d4ff080bed60f6e0f0d83..2e4ebf2c244e9e38c0e0bf8c827d53ac79a45f75 100644 (file)
@@ -341,40 +341,27 @@ namespace System.Web.UI
 
                void AddAssembliesInBin ()
                {
-                       foreach (string bindir in HttpApplication.PrivateBinPath) {
-                               if (!Directory.Exists (bindir))
-                                       continue;
-
-                               string [] binDlls = Directory.GetFiles (bindir, "*.dll");
-                               foreach (string s in binDlls) {
-                                       try {
-                                               Assembly assembly = Assembly.LoadFrom (s);
-                                               AddAssembly (assembly, true);
-                                       } catch (Exception e) {
-                                               throw new Exception ("Error while loading " + s, e);
-                                       }
+                       foreach (string s in HttpApplication.BinDirectoryAssemblies) {
+                               try {
+                                       Assembly assembly = Assembly.LoadFrom (s);
+                                       AddAssembly (assembly, true);
+                               } catch (Exception e) {
+                                       throw new Exception ("Error while loading " + s, e);
                                }
-                                       
                        }
                }
 
                Assembly LoadAssemblyFromBin (string name)
                {
                        Assembly assembly = null;
-                       foreach (string bindir in HttpApplication.PrivateBinPath) {
-                               if (!Directory.Exists (bindir))
+                       foreach (string dll in HttpApplication.BinDirectoryAssemblies) {
+                               string fn = Path.GetFileName (dll);
+                               fn = Path.ChangeExtension (fn, null);
+                               if (fn != name)
                                        continue;
 
-                               string [] binDlls = Directory.GetFiles (bindir, "*.dll");
-                               foreach (string dll in binDlls) {
-                                       string fn = Path.GetFileName (dll);
-                                       fn = Path.ChangeExtension (fn, null);
-                                       if (fn != name)
-                                               continue;
-
-                                       assembly = Assembly.LoadFrom (dll);
-                                       return assembly;
-                               }
+                               assembly = Assembly.LoadFrom (dll);
+                               return assembly;
                        }
                        
                        return null;
@@ -402,13 +389,12 @@ namespace System.Web.UI
                internal Type GetTypeFromBin (string typeName)
                {
                        Type result = null;
-                       Type type = null;
                        
 #if NET_2_0
                        IList toplevelAssemblies = BuildManager.TopLevelAssemblies;
                        if (toplevelAssemblies != null && toplevelAssemblies.Count > 0) {
                                foreach (Assembly asm in toplevelAssemblies) {
-                                       type = asm.GetType (typeName, false);
+                                       Type type = asm.GetType (typeName, false);
                                        if (type != null) {
                                                if (result != null)
                                                        throw new HttpException (String.Format ("Type {0} is not unique.", typeName));
@@ -418,22 +404,17 @@ namespace System.Web.UI
                        }
 #endif
 
-                       foreach (string bindir in  HttpApplication.PrivateBinPath) {
-                               if (!Directory.Exists (bindir))
-                                       continue;
-                       
-                               string [] binDlls = Directory.GetFiles (bindir, "*.dll");
-                               foreach (string dll in binDlls) {
-                                       Assembly assembly = Assembly.LoadFrom (dll);
-                                       type = assembly.GetType (typeName, false);
-                                       if (type != null) {
-                                               if (result != null) 
-                                                       throw new HttpException (String.Format ("Type {0} is not unique.", typeName));
+                       foreach (string dll in HttpApplication.BinDirectoryAssemblies) {
+                               Assembly assembly = Assembly.LoadFrom (dll);
+                               Type type = assembly.GetType (typeName, false);
+                               if (type != null) {
+                                       if (result != null) 
+                                               throw new HttpException (String.Format ("Type {0} is not unique.", typeName));
                                                
-                                               result = type;
-                                       } 
-                               }
+                                       result = type;
+                               } 
                        }
+
                        
                        if (result == null)
                                throw new HttpException (String.Format ("Type {0} not found.", typeName));
index 2ad5435143897c91e7b9140af0d0a321adcd3184..0e40dc0f9acb5c638c959aa816a853cd3c8971cb 100644 (file)
@@ -372,7 +372,7 @@ namespace System.Web.UI {
                        AddDependency (location);
                        string dirname = Path.GetDirectoryName (location);
                        bool doAddAssembly = true;
-                       foreach (string dir in HttpApplication.PrivateBinPath) {
+                       foreach (string dir in HttpApplication.BinDirectories) {
                                if (dirname == dir) {
                                        doAddAssembly = false;
                                        break;
@@ -387,14 +387,8 @@ namespace System.Web.UI {
 
                void AddAssembliesInBin ()
                {
-                       foreach (string bindir in HttpApplication.PrivateBinPath) {
-                               if (!Directory.Exists (bindir))
-                                       continue;
-
-                               string [] binDlls = Directory.GetFiles (bindir, "*.dll");
-                               foreach (string s in binDlls)
-                                       assemblies.Add (s);
-                       }
+                       foreach (string s in HttpApplication.BinDirectoryAssemblies)
+                               assemblies.Add (s);
                }
                
                internal virtual void AddInterface (string iface)
index f39c20f9e276bdbde8aaa40e7fc3010065c06d78..7316781bb0cf49d12941e38801de20a63bac3c23 100644 (file)
@@ -1,3 +1,18 @@
+2007-08-23  Marek Habersack  <mhabersack@novell.com>
+
+       * HttpApplication.cs: added a static array BinDirs which contains
+       the common bin directory names we can encounter.
+       Added internal static property IsRunningOnWindows.
+       Added internal enumerable property BinDirectories to iterate over
+       the full paths of the available binary directories.
+       Added internal enumerable property BinDirectoryAssemblies to
+       iterate over .dll files in the bin directories.
+       LoadTypeFromPrivateBin renamed to LoadTypeFromBin.
+       LoadTypeFromBin uses BinDirectoryAssemblies.
+       
+       * HttpApplicationFactory.cs: use HttpApplication.BinDirectories to
+       interate over the list of bin dirs.
+
 2007-08-21  Marek Habersack  <mhabersack@novell.com>
 
        * HttpApplicationFactory.cs: watch for changes in all the
index 71a7595fdc78030a2df6ae6cf14da28d21f78326..9976214e35eb9da5bf3be2629d1417aba33dbc71 100644 (file)
@@ -88,6 +88,8 @@ namespace System.Web {
        [ToolboxItem(false)]
        public class HttpApplication : IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable {
                object this_lock = new object();
+
+               internal static readonly string [] BinDirs = {"Bin", "bin"};
                
                HttpContext context;
                HttpSessionState session;
@@ -1305,7 +1307,53 @@ namespace System.Web {
                                        yield return Path.Combine (baseDir, d);
                        }
                }
-                       
+
+               internal static bool IsRunningOnWindows {
+                        get {
+                               PlatformID pid = Environment.OSVersion.Platform;        
+                               return ((int) pid != 128 && (int) pid != 4);
+                       }
+                }
+               
+               internal static IEnumerable BinDirectories
+               {
+                       get {
+                               AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
+                               string baseDir = setup.ApplicationBase;
+                               string bindir;
+
+                               if (Environment.GetEnvironmentVariable ("MONO_IOMAP") != null || IsRunningOnWindows)
+                                       yield return Path.Combine (baseDir, "bin");
+                               else {
+                                       foreach (string dir in BinDirs) {
+                                               bindir = Path.Combine (baseDir, dir);
+                                               if (!Directory.Exists (bindir))
+                                                       continue;
+                                               yield return bindir;
+                                       }
+                               }
+                       }
+               }
+
+               internal static string[] BinDirectoryAssemblies
+               {
+                       get {
+                               ArrayList binDlls = null;
+                               string[] dlls;
+                               
+                               foreach (string bindir in BinDirectories) {
+                                       if (binDlls == null)
+                                               binDlls = new ArrayList ();
+                                       dlls = Directory.GetFiles (bindir, "*.dll");
+                                       binDlls.AddRange (dlls);
+                               }
+
+                               if (binDlls == null)
+                                       return new string[] {};
+                               return (string[])binDlls.ToArray (typeof (string));
+                       }
+               }
+                                       
                internal static Type LoadType (string typeName)
                {
                        return LoadType (typeName, false);
@@ -1337,7 +1385,7 @@ namespace System.Web {
                        }
 #endif
 
-                       type = LoadTypeFromPrivateBin (typeName);
+                       type = LoadTypeFromBin (typeName);
                        if (type != null)
                                return type;
                        
@@ -1347,23 +1395,17 @@ namespace System.Web {
                        return null;
                }
 
-               internal static Type LoadTypeFromPrivateBin (string typeName)
+               internal static Type LoadTypeFromBin (string typeName)
                {
                        Type type = null;
                        
-                       foreach (string dir in PrivateBinPath) {
-                               if (!Directory.Exists (dir))
+                       foreach (string s in BinDirectoryAssemblies) {
+                               Assembly binA = Assembly.LoadFrom (s);
+                               type = binA.GetType (typeName, false);
+                               if (type == null)
                                        continue;
-                       
-                               string[] binDlls = Directory.GetFiles(dir, "*.dll");
-                               foreach (string s in binDlls) {
-                                       Assembly binA = Assembly.LoadFrom (s);
-                                       type = binA.GetType (typeName, false);
-                                       if (type == null)
-                                               continue;
                                
-                                       return type;
-                               }
+                               return type;
                        }
 
                        return null;
index 36364ac288605259cf35147e1bfb02efb899cd63..591097cf08d4e1480afdca70511218527f9b7d05 100644 (file)
@@ -445,7 +445,7 @@ namespace System.Web {
                                factory.InitType (context);
                                lock (factory) {
                                        if (factory.app_start_needed) {
-                                               foreach (string dir in HttpApplication.PrivateBinPath)
+                                               foreach (string dir in HttpApplication.BinDirectories)
                                                        WatchLocationForRestart (dir, "*.dll");
 #if NET_2_0
                                                WatchLocationForRestart ("App_Code", "*", true);