Bug 42 - Exception 'TypeConverter cannot convert from System.String' when specifying soapExtensionReflectorTypes
Summary: Exception 'TypeConverter cannot convert from System.String' when specifying s...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web.Services ()
Version: master
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-07-22 10:06 UTC by Horst Kakuschke
Modified: 2011-07-28 10:25 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Diff of the suggested patch (1.18 KB, application/octet-stream)
2011-07-22 10:06 UTC, Horst Kakuschke
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Horst Kakuschke 2011-07-22 10:06:14 UTC
Created attachment 9 [details]
Diff of the suggested patch

When specifying saopExtensionReflectorTypes in the configuration file for an ASP.NET web service like this:

<system.web>
	<webServices>
		<soapExtensionReflectorTypes>
			<add type="My.Soap.Reflector.Class, My.Assembly" />
		</soapExtensionReflectorTypes>
	</webServices>
</system.web>

we get an exception as soon as these soapExtensionReflectorTypes are referenced by calling the web service with ...?wsdl :

System.Configuration.ConfigurationErrorsException: The value for the property 'type' is not valid. The error is: TypeConverter cannot convert from System.String.
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationElementCollection.OnDeserializeUnrecognizedElement (System.String elementName, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationSection.DoDeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0 
  at System.Web.Services.Configuration.WebServicesSection.get_Current () [0x00000] in <filename unknown>:0 
  at System.Web.Services.Configuration.WebServicesSection.IsSupported (WebServiceProtocols proto) [0x00000] in <filename unknown>:0 
  at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication+<Pipeline>c__Iterator6.MoveNext () [0x00000] in <filename unknown>:0 


The reason for this is a missing type converter in the TypeElement class in mcs/class/System.Web.Services/System.Web.Services.Configuration/TypeElement.cs - what we need here is a type conversion from String to Type (which is provided by class TypeTypeConverter).
So it should be

 static TypeElement ()
 {
-	typeProp = new ConfigurationProperty ("type", typeof (Type), null, ConfigurationPropertyOptions.IsKey);
+	typeProp = new ConfigurationProperty ("type", typeof (Type), null, new TypeTypeConverter(),
+											  null, ConfigurationPropertyOptions.IsKey);
	. . .

and

+	[TypeConverter (typeof (TypeTypeConverter))]
 	[ConfigurationProperty ("type", Options = ConfigurationPropertyOptions.IsKey)]
 	public Type Type {
 		get { return (Type) base [typeProp];}

Can you please review this fix and check it into the appropiate braches?

Thanks,
Horst
Comment 1 Miguel de Icaza [MSFT] 2011-07-22 11:33:13 UTC
Hello Horst,

Could you make that change by forking Mono on github?

Fork the tree at github.com/mono/mono, make the changes and submit a pull request.
Comment 2 Horst Kakuschke 2011-07-22 12:46:11 UTC
Hello Miguel,

let me try to... (I'm not used to Git - still working with SVN)

I created a branch called "BUG_42", made the changes and commited them.
How do I submit a pull request?

Thanks,
Horst
Comment 3 Horst Kakuschke 2011-07-22 13:12:09 UTC
Helllo Miguel,

sorry, please just forget my last comment.
I just did the RTFM - the pull request will be up in a few minutes.

Thanks,
Horst
Comment 4 Miguel de Icaza [MSFT] 2011-07-28 10:25:33 UTC
Thanks, patch applied