Bug 13208 - System.Diagnostics.Trace.WriteLine sometimes fails when called at startup
Summary: System.Diagnostics.Trace.WriteLine sometimes fails when called at startup
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-07-12 11:19 UTC by Bjoern Gdanietz
Modified: 2013-07-12 11:19 UTC (History)
1 user (show)

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

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 13208 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 Bjoern Gdanietz 2013-07-12 11:19:21 UTC
When starting up my application it starts a thread for logging issues. The very first thing the thread does is using System.Diagnostics.Trace.WriteLine.

private static void LogThreadFunc()
    Trace.WriteLine("Logging thread started.");

Unfortunately sometimes the runtime system might not be ready yet for a Trace.WriteLine as the following exception suggests:

Unhandled Exception:
System.InvalidOperationException: ConfigurationSectionGroup cannot be edited until it is added to a Configuration instance as its descendant
  at System.Configuration.ConfigurationSectionGroup.get_Config () [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationSectionGroup.get_Sections () [0x00000] in <filename unknown>:0
  at System.Configuration.Configuration.get_Sections () [0x00000] in <filename unknown>:0
  at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationSettings.GetConfig (System.String sectionName) [0x00000] in <filename unknown>:0
  at System.Diagnostics.DiagnosticsConfiguration.get_Settings () [0x00000] in <filename unknown>:0
  at System.Diagnostics.TraceImpl.InitOnce () [0x00000] in <filename unknown>:0
  at System.Diagnostics.TraceImpl.get_Listeners () [0x00000] in <filename unknown>:0
  at System.Diagnostics.TraceImpl.get_ListenersSyncRoot () [0x00000] in <filename unknown>:0
  at System.Diagnostics.TraceImpl.WriteLine (System.String message) [0x00000] in <filename unknown>:0
  at System.Diagnostics.Trace.WriteLine (System.String message) [0x00000] in <filename unknown>:0
  at LogManager.LogThreadFunc () [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: ConfigurationSectionGroup cannot be edited until it is added to a Configuration instance as its descendant