Bug 59200 - System.CodeDom.Compiler.CodeDomConfigurationHandler not found in Mono 5.2.0
Summary: System.CodeDom.Compiler.CodeDomConfigurationHandler not found in Mono 5.2.0
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 5.2 (2017-04)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Egorbo
Depends on:
Reported: 2017-09-04 00:30 UTC by Mick Byrne
Modified: 2018-01-05 13:27 UTC (History)
4 users (show)

See Also:
Tags: bugpool-archive
Is this bug a regression?: Yes
Last known good build:

Stack trace of exception (3.31 KB, text/plain)
2017-09-04 00:30 UTC, Mick Byrne
Sample App.config file using <configSections> (1.27 KB, text/x-tex)
2017-09-04 00:31 UTC, Mick Byrne

Description Mick Byrne 2017-09-04 00:30:54 UTC
Created attachment 24535 [details]
Stack trace of exception

The `System.CodeDom.Compiler.CodeDomConfigurationHandler` class does not seem to be present in Mono 5.2.0, though it was definitely there in pre-5.x versions and still exists in the .NET 4.7 framework.

This class is used to parse App.config files that use custom <configSections> elements.

I've attached the full stack trace from the exception we get, along with a trimmed version of a sample App.config file that triggers the error. 

In this instance, we're running a .NET 4.5.2 console application on the Mono framework version on a Mac running OSX 10.12.6.
Comment 1 Mick Byrne 2017-09-04 00:31:25 UTC
Created attachment 24536 [details]
Sample App.config file using <configSections>
Comment 2 Mick Byrne 2017-09-04 05:26:45 UTC
Not sure if anyone has looked at this at all, but for what it's worth, the specific code to reproduce the error involves looping through all the available config sections and testing their type.

This is essentially the code that's causing the error:

	var startupAssembly = Server.StartupClass.Assembly;
	if (Configs.TryGetValue(startupAssembly, out configuration))
		foreach (ConfigurationSection section in config.Sections)
			if (section is AppSettingsSections) // Should throw an error when it gets to the 'system.codeDom' section
				// etc...
Comment 3 Mick Byrne 2017-09-04 05:42:40 UTC
Sorry, that was an incomplete code sample, with bits and pieces. I've prepared a single class that triggers this error, code below. Only dependencies are System.Configuration and the Nancy package, which has a handy assembly scanner):

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Reflection;

namespace TestingTesting123
	class MainClass
		public static void Main(string[] args)
			Console.WriteLine("Hello World!");

			Dictionary<Assembly, Configuration> Configs = new Dictionary<Assembly, Configuration>();

			string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;
			string executableDirectory = (System.IO.Path.GetDirectoryName(executable));
			foreach (var assembly in Nancy.Bootstrapper.AppDomainAssemblyTypeScanner.Assemblies)
				var configuration = ConfigurationManager.OpenExeConfiguration(assembly.Location);
				if (configuration != null)
					Configs[assembly] = configuration;

			Type startupClass = typeof(MainClass);
			var startupAssembly = startupClass.Assembly;

			Configuration config = null;
			if (Configs.TryGetValue(startupAssembly, out config))
				Console.WriteLine("Looping through config with keys...");
				foreach (string sectionName in config.Sections.Keys)
					Console.WriteLine("Found section key : " + sectionName);
				foreach (ConfigurationSection section in config.Sections)
					Console.WriteLine("Found section : " + section.SectionInformation.Name);
Comment 4 Egorbo 2017-11-22 16:25:03 UTC
Looks like we can just remove the handler from machine config https://github.com/mono/mono/pull/6070
Comment 5 Ludovic Henry 2017-12-01 19:12:48 UTC
Merged to master with https://github.com/mono/mono/commit/076632c3e911e062458d4752a9cc0d7ffebc29cb

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