Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SynchronizationLockException + Logging

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?

like image 540
Jaster Avatar asked Nov 11 '10 10:11

Jaster


3 Answers

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

like image 124
Rory MacLeod Avatar answered Nov 12 '22 12:11

Rory MacLeod


We have fixed this. Check out the latest version via nuget.

like image 3
Grigori Melnik Avatar answered Nov 12 '22 10:11

Grigori Melnik


I found a "solution". Consider to this post there is an issue within the Unity part of the enterprise lib. Since every component is build up using unity you will alsways get those exceptions. So the "solution" is to disable the breaking for SynchronizationLockException; this is done via the exception settings menu where you usually turn the breaking for handled exceptions on.

like image 1
Jaster Avatar answered Nov 12 '22 11:11

Jaster