[Mono-bugs] [Bug 81071][Nor] New - ProvidersHelper can not load type from App_Code assembly [w/ fix]
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Mar 7 19:52:39 EST 2007
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by mmorano at mikeandwan.us.
http://bugzilla.ximian.com/show_bug.cgi?id=81071
--- shadow/81071 2007-03-07 19:52:39.000000000 -0500
+++ shadow/81071.tmp.9319 2007-03-07 19:52:39.000000000 -0500
@@ -0,0 +1,102 @@
+Bug#: 81071
+Product: Mono: Class Libraries
+Version: 1.2
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Web
+AssignedTo: mhabersack at novell.com
+ReportedBy: mmorano at mikeandwan.us
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: ProvidersHelper can not load type from App_Code assembly [w/ fix]
+
+Description of Problem:
+Created a custom Membership and Role provider for my site by creating these
+classes under the App_Code directory. Currently with a fresh version from
+SVN, the application fails to load the provider as it can not find the type
+in any assembly.
+
+Steps to reproduce the problem:
+1. Create application with custom provider defined in the App_Code directory
+2. Try to access the site
+
+Actual Results:
+An error is thrown indicating that the type can not be loaded. The stack
+trace points to the ProviderHelper.InstantiateProvider(x,y) method.
+
+Expected Results:
+Page loads, and provider is usable.
+
+How often does this happen?
+always
+
+Additional Information:
+I have tracked this down to the ProviderHelper not finding the App_Code
+dll. I have included the patch below which addresses this issue, by
+looking in the App_Code assembly if it was not found using the existing
+checks. The following is the patch illustrating this, and is similar to
+another bug I reported here:
+http://bugzilla.ximian.com/show_bug.cgi?id=78797. It uses the same
+technique to get the reference to the App_Code assembly - via the BuildManager.
+
+Here is the diff:
+
+===================================================================
+--- ProvidersHelper.cs (revision 73878)
++++ ProvidersHelper.cs (working copy)
+@@ -29,13 +29,15 @@
+
+ #if NET_2_0
+
+-using System;
++using System;
++using System.Collections;
+ using System.Configuration;
+ using System.Configuration.Provider;
+ using System.Data.Common;
+ using System.Data.SqlClient;
+ using System.IO;
+ using System.Reflection;
++using System.Web.Compilation;
+
+ namespace System.Web.Configuration {
+
+@@ -55,7 +57,23 @@
+ break;
+ }
+ }
+-
++
++ // check App_Code dll
++ if (settingsType == null)
++ {
++ IList appCode =
+BuildManager.TopLevelAssemblies;
++
++ if(appCode != null && appCode.Count > 0)
++ {
++ Assembly appCodeAssembly =
+appCode[0] as Assembly;
++
++ if(appCodeAssembly != null)
++ {
++ settingsType =
+appCodeAssembly.GetType(providerSettings.Type);
++ }
++ }
++ }
++
+ if (settingsType == null)
+ throw new ConfigurationErrorsException
+(String.Format ("Could not find type: {0}", providerSettings.Type));
+ if (!providerType.IsAssignableFrom (settingsType))
+
+
+Thanks,
+Mike
More information about the mono-bugs
mailing list