views:

156

answers:

2

I have an application that was working fine that uses Windsor for IoC. I want to log the method calls, parameters, and execution time of all calls made to components instantiated by Windsor, so I implemented a LoggingInterceptor that implements IInterceptor, that contains:

Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
invocation.Proceed();  // EXCEPTION IS THROWN HERE
sw.Stop();
Logger.Debug(.....

Now operations that previously worked fine are throwing VerificationExceptions with the following message:

Method Repositories.RepositoryBase.GetAll: type argument 'ET' violates the constraint of type parameter 'ET'.

The signature of the method is:

public IList<ET> GetAll<ET>() where ET : EntityBase2, IEntity2

(where EntityBase2 and IEntity2 are from LLBLGenPro)

The caller of the method is as follows:

public IList<ServerEntity> GetServers()
{
   return GetRepository<IServerRepository>().GetAll<ServerEntity>();
}

(where GetRepository<>() is just a wrapper around ServiceLocator)

If I comment out the interceptor from the castle configuration, it all works fine again.

Why is this happening now, and is there a fix so I can use my logging interceptor?

thanks

A: 

If you're using an older version of Windsor (RC3 or earlier), I don't think it supports interceptors on Generic types because the old DynamicProxy doesn't support it.

You might try updating to the latest release of Windsor. It uses DynamicProxy2 under the hood, which works with generic types.

Craig Vermeer
A: 

Does this happen only under Visual Studio debugger?

Does this happen on the latest trunk version of Castle as well? (which you can find here)

Krzysztof Koźmic