Bug 616845

Summary: webHttpBinding element cannot be customized due to a missing converter in WebHttpBindingElement.cs
Product: [Mono] Mono: Class Libraries Reporter: Clovis Ribeiro <clovis.ribeiro>
Component: WCFAssignee: Mono Bugs <mono-bugs>
Status: NEW --- QA Contact: Mono Bugs <mono-bugs>
Severity: Critical    
Priority: P5 - None    
Version: 2.6.x   
Target Milestone: ---   
Hardware: x86-64   
OS: Mac OS X 10.6   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: No
Marketing QA Status: --- IT Deployment: ---

Description Clovis Ribeiro 2010-06-23 19:47:08 UTC
In any WCF configuration file, if you try to customize webHttpBinding by adding something like:

<configuration> 
  <system.serviceModel>
       ...
      <webHttpBinding>
         <binding name="abc">
         </binding>
       </webHttpBinding>
        ....
  </system.serviceModel>
</configuration>  

The result is a crash with the following output:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.ServiceModel.Configuration.WebHttpBindingElement ---> System.Configuration.ConfigurationErrorsException: The default value for property 'writeEncoding' has a different type than the one of the property itself: expected System.Text.Encoding but was System.String

This points out to a missing conversion in WebHttpBindingElement.cs in line 231:

		[TypeConverter ()]
		[ConfigurationProperty ("writeEncoding",
			 DefaultValue = "utf-8",
			 Options = ConfigurationPropertyOptions.None)]
		public Encoding WriteEncoding {
			get { return (Encoding) base [write_encoding]; }
			set { base [write_encoding] = value; }
		}

[TypeConverter()] should probably have a "typeof(EncodingConverter)" as a parameter to force string to Encoding conversion. Without that, even if you do not use  writeEncoding, as the default value is a string, the element will fail.