2009-07-13 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Mon, 13 Jul 2009 19:52:03 +0000 (19:52 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Mon, 13 Jul 2009 19:52:03 +0000 (19:52 -0000)
* ProvidersHelper.cs: InstantiateProvider doesn't have to
explicitly look for types in App_Code assemblies - this is done in
HttpApplication.LoadType.

2009-07-13  Marek Habersack  <mhabersack@novell.com>

* AppCodeCompiler.cs: wrap HttpApplication.LoadTypeFromBin call in
try/catch, so that we can wrap the possible exception in
HttpException.

2009-07-13  Marek Habersack  <mhabersack@novell.com>

* HttpApplication.cs: LoadType - wrap call to LoadTypeFromBin in
try/catch so that we can decide whether or not to throw
exceptions. LoadTypeFromBin - ignore the FileLoadException and
BadImageException exceptions as they don't matter in this
context.

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

mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.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/ChangeLog
mcs/class/System.Web/System.Web/HttpApplication.cs

index 71ac1d1452e111e5f1ed05c970e0d84f14726e29..2e6b3155b87a5d516689afcfd794af4cacdb69e6 100644 (file)
@@ -668,9 +668,17 @@ namespace System.Web.Compilation
                                } else
                                        return;
 
-                               if (HttpApplication.LoadTypeFromBin (providerTypeName) == null)
-                                       throw new HttpException (String.Format ("Profile provider type not found: {0}",
-                                                                               providerTypeName));
+                               Exception noTypeException = null;
+                               Type ptype = null;
+                               
+                               try {
+                                       ptype = HttpApplication.LoadTypeFromBin (providerTypeName);
+                               } catch (Exception ex) {
+                                       noTypeException = ex;
+                               }
+
+                               if (ptype == null)
+                                       throw new HttpException (String.Format ("Profile provider type not found: {0}", providerTypeName), noTypeException);
                        }
                }
 
index dffca85f151902564ac7503aca8fd67a9d027a99..c0e4d2aa42b270d3dc1e9751285c26f3a56bfd3c 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-13  Marek Habersack  <mhabersack@novell.com>
+
+       * AppCodeCompiler.cs: wrap HttpApplication.LoadTypeFromBin call in
+       try/catch, so that we can wrap the possible exception in
+       HttpException.
+
 2009-07-09  Marek Habersack  <mhabersack@novell.com>
 
        * DefaultResourceProvider.cs, DefaultResourceProviderFactory.cs:
index 8c0156f13895041fdb811bd975f364111f1b7fa4..165a8dd22a6eb82d14d33420dd6c67e0b04f412a 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-13  Marek Habersack  <mhabersack@novell.com>
+
+       * ProvidersHelper.cs: InstantiateProvider doesn't have to
+       explicitly look for types in App_Code assemblies - this is done in
+       HttpApplication.LoadType.
+
 2009-07-09 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * WebConfigurationHost.cs: null means MachineToApplication.
index e9b8dca4a8d064289ef8fbedfb5259ef09aa3db6..becc4914b04660acf2b94d28842d9b5c72b5e8b4 100644 (file)
@@ -48,27 +48,6 @@ namespace System.Web.Configuration {
                public static ProviderBase InstantiateProvider (ProviderSettings providerSettings, Type providerType)
                {
                        Type settingsType = HttpApplication.LoadType (providerSettings.Type);
-                       
-                       if (settingsType == null)
-                               settingsType = HttpApplication.LoadTypeFromBin (providerSettings.Type);
-
-                       // check App_Code dlls
-                       if (settingsType == null) {
-                               IList appCode = BuildManager.CodeAssemblies;
-
-                               if (appCode != null && appCode.Count > 0) {
-                                       Assembly asm;
-                                       foreach (object o in appCode) {
-                                               asm = o as Assembly;
-                                               if (asm == null)
-                                                       continue;
-                                               settingsType = asm.GetType (providerSettings.Type);
-                                               if (settingsType != null)
-                                                       break;
-                                       }
-                               }
-                       }
-
                        if (settingsType == null)
                                throw new ConfigurationErrorsException (String.Format ("Could not find type: {0}",
                                                                                       providerSettings.Type));
index b5a3fca58f656da332806788c62d34c0ff110a28..a8373bfc03070e90e346dd724fbde675302b2811 100644 (file)
@@ -1,3 +1,11 @@
+2009-07-13  Marek Habersack  <mhabersack@novell.com>
+
+       * HttpApplication.cs: LoadType - wrap call to LoadTypeFromBin in
+       try/catch so that we can decide whether or not to throw
+       exceptions. LoadTypeFromBin - ignore the FileLoadException and
+       BadImageException exceptions as they don't matter in this
+       context.
+
 2009-07-13  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * HttpResponseStream.cs: Added argument checks to Write. Modified
index cb28034f17999bff2538e615d3f61e791d7d447f..84760b078abd0e4cffbed3ff07e114eefaae21ca 100644 (file)
@@ -1845,12 +1845,19 @@ namespace System.Web {
                        }
 #endif
 
-                       type = LoadTypeFromBin (typeName);
+                       Exception loadException = null;
+                       try {
+                               type = null;
+                               type = LoadTypeFromBin (typeName);
+                       } catch (Exception ex) {
+                               loadException = ex;
+                       }
+                       
                        if (type != null)
                                return type;
 #endif
                        if (throwOnMissing)
-                               throw new TypeLoadException (String.Format ("Type '{0}' cannot be found", typeName));
+                               throw new TypeLoadException (String.Format ("Type '{0}' cannot be found", typeName), loadException);
                        
                        return null;
                }
@@ -1860,7 +1867,18 @@ namespace System.Web {
                        Type type = null;
                        
                        foreach (string s in BinDirectoryAssemblies) {
-                               Assembly binA = Assembly.LoadFrom (s);
+                               Assembly binA = null;
+                               
+                               try {
+                                       binA = Assembly.LoadFrom (s);
+                               } catch (FileLoadException) {
+                                       // ignore
+                                       continue;
+                               } catch (BadImageFormatException) {
+                                       // ignore
+                                       continue;
+                               }
+                               
                                type = binA.GetType (typeName, false);
                                if (type == null)
                                        continue;