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 (show other bugs)
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)

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


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.

Note You need to log in before you can comment on or make changes to this bug.