Bug 42763 - Updating the App.config file after referencing service model section causes that section to be deleted.
Summary: Updating the App.config file after referencing service model section causes t...
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: 4.6.0 (C8)
Hardware: PC All
: Normal normal
Target Milestone: Future Release
Assignee: Bugzilla
Depends on:
Reported: 2016-07-22 19:37 UTC by Chris Capon
Modified: 2017-09-06 16:55 UTC (History)
2 users (show)

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

Sample project solution which demonstrates the problem. (4.42 KB, application/zip)
2016-07-22 19:37 UTC, Chris Capon

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 for Bug 42763 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Chris Capon 2016-07-22 19:37:53 UTC
Created attachment 16766 [details]
Sample project solution which demonstrates the problem.

Mono version 4.2.1 (Debian

When modifying the App.config file from within an application, if the ServiceModel Client section is referenced in the code, that section will be excluded from the updated config file.

Attached is a project which demonstrates the problem.  Execute the "compile-project" shell script under Linux to reproduce the problem.

1) The App.config file contains a section for <system.serviceModel><client>.

2) When the code executes, ConfigurationManager.OpenExeConfiguration is use to retrieve the config file.

3) A key is added to the <appSettings> section.

4) Calling Configuration.Save() updates the App.config file.

The above steps work properly under both .NET and Mono.

However, if the ServiceModelSectionGroup.ClientSection is referenced within the code, under Mono, the <system.serviceModel><client> section will be removed from the updated App.config file.

This does not happen with .NET.

Within the Program.cs file, a "#if true" can be toggled to demonstrate the problem.  See how the resulting application config file changes when it flips from true to false.

Comment 1 Rodrigo Kumpera 2016-07-23 00:36:13 UTC
I can reproduce with the provided test case on OSX 4.6.0.