Bug 616845 - webHttpBinding element cannot be customized due to a missing converter in WebHttpBindingElement.cs
Summary: webHttpBinding element cannot be customized due to a missing converter in Web...
Status: NEW
Alias: None
Product: Mono: Class Libraries
Classification: Mono
Component: WCF (show other bugs)
Version: 2.6.x
Hardware: x86-64 Mac OS X 10.6
: P5 - None : Critical
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-23 19:47 UTC by Clovis Ribeiro
Modified: 2010-06-23 19:47 UTC (History)
0 users

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: No
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.