Bug 18037 - XmlAttributeOverrides are not honored
Summary: XmlAttributeOverrides are not honored
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 7.0.7
Hardware: PC Windows
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-02-26 19:43 UTC by Adam
Modified: 2017-01-17 19:27 UTC (History)
5 users (show)

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

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 Developer Community or GitHub 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 Adam 2014-02-26 19:43:59 UTC
Using the following code:

            var over = new XmlAttributeOverrides();

            over.Add(typeof(BasicHttpBinding), "ProxyAddress", new XmlAttributes() { XmlIgnore = true });

            // also tried with          
            // over.Add(typeof(HttpBindingBase), "ProxyAddress", new XmlAttributes() { XmlIgnore = true });

            XmlSerializer ser = new XmlSerializer(typeof(BasicHttpBinding), over);


Fails with Exception:

There was an error reflecting field 'ProxyAddress'. ---> System.InvalidOperationException: There was an error reflecting type 'System.Uri'. ---> System.InvalidOperationException: System.Uri cannot be serialized because it does not have a default public constructor

This prevents the deserialization of this type.
Comment 1 Sebastien Pouliot 2014-02-26 21:41:19 UTC
I suspect the serializer requires some special support as System.Uri does not have a default (public) constructor.

Note: I had a look to see if it was linker related - but the issue exists even when not linking (e.g. simulator).
Comment 2 Sebastien Pouliot 2017-01-17 19:27:46 UTC
This was fixed at some point, likely by including MS RS code into the latest releases.

To make the above snippet work you have to add

> var bhb = new BasicHttpBinding ();

or something similar so the linker will not remove the default .ctor from the type being used.