SynchronizationLockException + Logging

Jaster picture Jaster · Nov 11, 2010 · Viewed 8.2k times · Source

I just started with v5 of the enterprise lib and seem to encounter some strange issues. As usually I started with logging. I just added the required references and execute the following code:

Logger.Write("test");

Nothing special so far. Checking the output I found a quite strange issue; when the code is called the first time and all required libs are loaded there seem to be exceptions...

A first chance exception of type 'System.Threading.SynchronizationLockException' occurred in Microsoft.Practices.Unity.dll
A first chance exception of type 'System.Threading.SynchronizationLockException' occurred in Microsoft.Practices.Unity.dll

Since I work with cought exceptions turned on, this is quite annoying. Any idea what it is or how to get rid of it?

Further i would like to add a Trace Listener to print all loging into the VS output. But it seems that the "System Diagnostings Trace Listener" does not support a formatter, which results in a flooded output. Do i still have to write a custom listener (as i used to do in v3) to achive this very basic task?

Answer

Rory MacLeod picture Rory MacLeod · Jan 2, 2011

I resolved the SynchronizationLockException issue by swapping out the UnityDefaultBehaviorExtension. See Can Unity be made to not throw SynchronizationLockException all the time?