views:

19

answers:

0

Inside Global.asax.cs I get: Object synchronization method was called from an unsynchronized block of code

protected void Application_Start()
    {
        InitContainer();

        AreaRegistration.RegisterAllAreas();

        RegisterRoutes(RouteTable.Routes);

        ControllerBuilder.Current.SetControllerFactory(typeof(UnityControllerFactory));
        CheckForAndMinify();
        Logger.Write("test"); //exception
       // if (System.Diagnostics.Debugger.IsAttached)
           // MvcContrib.Routing.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
        //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

    }

Environment:

  • Asp.net Mvc2
  • VS2010
  • Windows7 Enterprise 64bit
  • Unity framework starts up before this logging code

Relevant web.config entries:

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>

and

    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
        <add name="GeneralRolling" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="~\App_Data\rolling2.log" formatter="Text Formatter" rollInterval="Day" rollSizeKB="2056" maxArchivedFiles="2" filter="Warning"/>
        <add name="EspionageRolling" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="~\App_Data\EspRolling.log" formatter="Text Formatter" rollInterval="Day" rollSizeKB="1024" maxArchivedFiles="2" traceOutputOptions="DateTime"/>
        <add name="SnapshotRolling" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="~\App_Data\SnapRolling.log" formatter="Text Formatter" rollInterval="Day" rollSizeKB="1024" maxArchivedFiles="2" traceOutputOptions="DateTime"/>
    </listeners>
    <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Title:{title}{newline}&#xA;Category: {category}{newline}&#xA;Message: {message}{newline}&#xA;Timestamp: {timestamp}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter"/>
    </formatters>
    <categorySources>
        <add switchValue="All" name="General">
            <listeners>
                <add name="GeneralRolling"/>
            </listeners>
        </add>
        <add switchValue="All" name="Espionage">
            <listeners>
                <add name="EspionageRolling"/>
            </listeners>
        </add>
        <add switchValue="All" name="SnapShot">
            <listeners>
                <add name="SnapshotRolling"/>
            </listeners>
        </add>
    </categorySources>
    <specialSources>
        <allEvents switchValue="All" name="All Events">
            <listeners>
                <add name="GeneralRolling"/>
            </listeners>
        </allEvents>
        <notProcessed switchValue="All" name="Unprocessed Category"/>
        <errors switchValue="All" name="Logging Errors &amp; Warnings">
            <listeners>
                <add name="GeneralRolling"/>
            </listeners>
        </errors>
    </specialSources>
</loggingConfiguration>

I'm trying to make sure the logger works on application startup so that the app doesn't startup, look correct and then dies as soon as the first attempt to log something happens.

The logging xml configuration has not changed, it was previously working. The major change was adding Unity, and switching the app from linq to sql. I have not confirmed if this code works in the deployment environment, so it could be that it works in the proper environment for some reason and not locally.