Bugzilla – Bug 616845
webHttpBinding element cannot be customized due to a missing converter in WebHttpBindingElement.cs
Last modified: 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.