SynchronizationLockException - The read lock is being released without being held

Aug 30, 2011 at 5:45 AM
Consider the following:
public interface ITest
{
}

public class Test : ITest
{
}

class Program
{
    static void Main(string[] args)
    {
        var test = PolicyInjection.Create<Test>();
    }
}

Throws: SynchronizationLockException. Why?
Consider:
public interface ITest
{
}

public class Test : ITest
{
}

class Program
{
    static void Main(string[] args)
    {
        var test = PolicyInjection.Create<Test, ITest>();
    }
}
This doesn't.
I would have expected something nicer than a SynchronizationLockException, that doesn't mean anything to me...
We had some legacy code using PolicyInjection as mentioned in the first code snippet. This started breaking as soon as we started using Enterprise Library 5.0
Aug 31, 2011 at 7:05 AM

Are you seeing a first chance exception in the debugger, or is it actually throwing an unhandled exception? If the former, this is expected (known issue) and shouldn't actually affect the output. If the latter, that's weird and shouldn't be happening.