Bug 53230 - PrivilegedConfigurationManager.GetSection might return something that is not a SystemDiagnosticsSection
Summary: PrivilegedConfigurationManager.GetSection might return something that is not ...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 4.8.0 (C9)
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-03-10 18:10 UTC by Josh Peterson
Modified: 2017-03-10 18:10 UTC (History)
1 user (show)

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 for Bug 53230 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Josh Peterson 2017-03-10 18:10:14 UTC
In the IL2CPP tests with the .NET 4.6 profile of the Mono class libraries, code like the following can cause a managed exception in DiagnosticsConfiguration::GetConfigSection.

        public class StuffToParse
            public string aName;

            public int aNumber;

        public void VerifyXmlDeserialization()
            const string xml = @"<?xml version='1.0' encoding='utf-8'?>
            <StuffToParse xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

            var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
            var serializer = new XmlSerializer(typeof(StuffToParse));
            var parsed = (StuffToParse)serializer.Deserialize(stream);

The call to PrivilegedConfigurationManager.GetSection returns a Hashtable instance, so the cast to SystemDiagnosticsSection fails. It looks like this is a difference in behavior between the reference source, where DiagnosticsConfiguration::GetConfigSection is defined, and the Mono class library code, where PrivilegedConfigurationManager.GetSection is defined.

This is not a great bug report though, as the code above does work in a standalone example. I'm unsure what it is about the IL2CPP tests and the Unity player implementation with IL2CPP that cause this issue. So there is a chance it is not really a bug on the Xamarin side. However, there is certainly a theoretical bug here.

One possible solution is in https://github.com/mono/mono/pull/4497.