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: RESOLVED FIXED
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
URL:
Depends on:
Blocks:
 
Reported: 2017-09-04 00:30 UTC by Mick Byrne
Modified: 2018-01-05 13:27 UTC (History)
4 users (show)

Tags: bugpool-archive
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


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 GitHub or Developer Community 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 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);
				}
			}
		}
	}
}
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