diff options
author | Marcos Henrich <marcoshenrich@gmail.com> | 2016-02-15 15:21:29 +0300 |
---|---|---|
committer | Marcos Henrich <marcoshenrich@gmail.com> | 2016-02-15 15:21:29 +0300 |
commit | 355d2c5eca6ec320ccd4097d7f196b26a721ea94 (patch) | |
tree | a1e286fd643b5e15411ad461e7cbcd9e6bb3fb06 /mcs/class/System.Configuration | |
parent | c1d81649cc1d16ee47bd6fb951e220d8aba6a1d0 (diff) | |
parent | f43a2563d723ded54767b6f83f7daf5a7d79ab2c (diff) |
Merge pull request #2400 from esdrubal/extrahead
[System] Fix extra head in config bug.
Diffstat (limited to 'mcs/class/System.Configuration')
-rw-r--r-- | mcs/class/System.Configuration/System.Configuration/Configuration.cs | 8 | ||||
-rw-r--r-- | mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs | 18 |
2 files changed, 24 insertions, 2 deletions
diff --git a/mcs/class/System.Configuration/System.Configuration/Configuration.cs b/mcs/class/System.Configuration/System.Configuration/Configuration.cs index 76037176690..fb48cc9664f 100644 --- a/mcs/class/System.Configuration/System.Configuration/Configuration.cs +++ b/mcs/class/System.Configuration/System.Configuration/Configuration.cs @@ -133,8 +133,12 @@ namespace System.Configuration { rootGroup.StreamName = streamName; } - if (streamName != null) - Load (); + try { + if (streamName != null) + Load (); + } catch (XmlException ex) { + throw new ConfigurationErrorsException (ex.Message, ex, streamName, 0); + } } internal Configuration Parent { diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs index d2e1a240f6d..7efff1dddff 100644 --- a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs +++ b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs @@ -627,5 +627,23 @@ namespace MonoTests.System.Configuration { Assert.AreEqual ("Server=(local);Initial Catalog=someDb;User Id=someUser;Password=somePassword;Application Name=someAppName;Min Pool Size=5;Max Pool Size=500;Connect Timeout=10;Connection Lifetime=29;", connString); } + + [Test] + public void BadConfig () + { + string xml = @" badXml"; + + var file = Path.Combine (tempFolder, "badConfig.config"); + File.WriteAllText (file, xml); + + try { + var fileMap = new ConfigurationFileMap (file); + var configuration = ConfigurationManager.OpenMappedMachineConfiguration (fileMap); + Assert.Fail ("Exception ConfigurationErrorsException was expected."); + } catch (ConfigurationErrorsException e) { + Assert.AreEqual (file, e.Filename); + } + + } } } |