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 (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-07-12 11:19 UTC by Bjoern Gdanietz
Modified: 2013-07-12 11:19 UTC (History)
1 user (show)

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


Attachments

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

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