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
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 5.2.0 (2017-04)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-04 00:30 UTC by Mick Byrne
Modified: 2017-09-11 11:19 UTC (History)
2 users (show)

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


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

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 5.2.0.215 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);
				}
			}
		}
	}
}

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