[Mono-bugs] [Bug 79396][Nor] New - Type not found when IConfigurationSectionHandler in bin
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Sep 14 13:14:38 EDT 2006
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 rmt512 at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=79396
--- shadow/79396 2006-09-14 13:14:38.000000000 -0400
+++ shadow/79396.tmp.21059 2006-09-14 13:14:38.000000000 -0400
@@ -0,0 +1,156 @@
+Bug#: 79396
+Product: Mono: Class Libraries
+Version: 1.0
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Web
+AssignedTo: gonzalo at ximian.com
+ReportedBy: rmt512 at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Type not found when IConfigurationSectionHandler in bin
+
+Description of Problem:
+
+I want to create a custom configuration section in web.config, by adding
+new section groups
+
+e.g., like mono.data
+
+<sectionGroup name="mono.data">
+ <section name="providers"
+type="Mono.Data.ProviderSectionHandler,Mono.Data" />
+ </sectionGroup>
+
+now, if an imlpementor of IConfigurationSectionHandler is defined in an
+assembly in bin, it is not found, and fails with this error
+
+System.Reflection.TargetInvocationException: Exception has been thrown by
+the target of an invocation. ---> System.TypeInitializationException: An
+exception was thrown by the type initializer for
+Accounts.Core.AddIns.AddInFactory --->
+System.Configuration.ConfigurationErrorsException: Type not found:
+'Accounts.Core.AddIns.AddInHandler' () ()
+ at System.Web.Configuration.WebConfigurationHost.GetConfigType
+(System.String typeName, Boolean throwOnError) [0x00000]
+ at System.Configuration.ConfigInfo.CreateInstance () [0x00000]
+ at System.Configuration.SectionInfo.CreateInstance () [0x00000]
+ at System.Configuration.Configuration.GetSectionInstance
+(System.Configuration.SectionInfo config, Boolean createDefaultInstance)
+[0x00000]
+ at System.Configuration.ConfigurationSectionCollection.get_Item
+(System.String name) [0x00000]
+ at System.Configuration.Configuration.GetSection (System.String path)
+[0x00000]
+ at
+System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection
+(System.String sectionName) [0x00000]
+ at System.Web.Configuration.Web20DefaultConfig.GetConfig (System.String
+sectionName) [0x00000]
+ at System.Configuration.ConfigurationSettings.GetConfig (System.String
+sectionName) [0x00000]
+ at Accounts.Core.AddIns.AddInFactory..cctor () [0x00000] --- End of inner
+exception stack trace ---
+
+
+This reminded me of bug
+
+http://bugzilla.ximian.com/show_bug.cgi?id=78321,
+[2.0] ObjectDataSource fails to find the specified type
+
+I applied the patch from Marek Habersack to
+
+mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs
+
+to get the attached diff, which makes it work to my satisfaction.
+
+Index: class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs
+===================================================================
+--- class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs
+ (revision 65334)
++++ class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs
+ (working copy)
+@@ -34,7 +34,9 @@
+ using System.Configuration;
+ using System.Configuration.Internal;
+ using System.Web.Util;
++using System.Reflection;
+
++
+ /*
+ * this class needs to be rewritten to support usage of the
+ * IRemoteWebConfigurationHostServer interface. Once that's done, we
+@@ -87,10 +89,56 @@
+ return configPath + "/" + locatinSubPath;
+ }
+
++ private static string privateBinPath;
++
++ private static string PrivateBinPath
++ {
++ get {
++ if (privateBinPath != null)
++ return privateBinPath;
++
++ AppDomainSetup setup =
+AppDomain.CurrentDomain.SetupInformation;
++ privateBinPath =
+Path.Combine(setup.ApplicationBase, setup.PrivateBinPath);
++
++ return privateBinPath;
++ }
++ }
++
++ private Type LoadType(string typeName)
++ {
++ Type type = null;
++ Assembly [] assemblies =
+AppDomain.CurrentDomain.GetAssemblies ();
++System.Console.WriteLine("doing my patch with "+typeName);
++
++ foreach (Assembly ass in assemblies) {
++ type = ass.GetType (typeName);
++ if (type == null)
++ continue;
++
++ return type;
++ }
++
++ if (!Directory.Exists (PrivateBinPath))
++ return null;
++
++ string[] binDlls =
+Directory.GetFiles(PrivateBinPath, "*.dll");
++ foreach (string s in binDlls) {
++ Assembly binA = Assembly.LoadFrom (s);
++ type = binA.GetType (typeName);
++ if (type == null)
++ continue;
++
++ return type;
++ }
++
++ return null;
++ }
++
+ [MonoTODO ("this should consult with the build provider
+machinery")]
+ public virtual Type GetConfigType (string typeName, bool
+throwOnError)
+ {
+- Type type = Type.GetType (typeName);
++ //Type type = Type.GetType (typeName);
++ Type type = LoadType(typeName);
+ if (type == null && throwOnError)
+ throw new ConfigurationErrorsException
+("Type not found: '" + typeName + "'");
+ return type;
+
+
+Thanks.
More information about the mono-bugs
mailing list