Skip to content

Random VerificationException/TypeLoadException #648

@dario-hd

Description

@dario-hd

We have a .NET 6 application exposing APIs and we are building dynamic proxies around all controllers and also around almost all services. Everything works fine, but we experience some issues when we deploy our application to production. The application is containerized and during deployment, which stops some old containers and starts new containers progressively, it randomly throws the following exception for some random methods:

System.Security.VerificationException: Method IEntityResolver.ResolveAsync: type argument 'TResult' violates the constraint of type parameter 'TEntity'.
   at Castle.Proxies.Invocations.IEntityResolver_ResolveAsync_3.InvokeMethodOnTarget()
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.DynamicProxy.AbstractInvocation.ProceedInfo.Invoke()
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)

The thing is that this doesn't happen all the time and it never happens locally or on our CI. Recently, this is happening very frequently, almost at every deployment, which is quite frequent. The thing that is changing in this regard might be the number of requests our APIs receive, which is constantly increasing.

To give some more details, here's the definition of the interface IEntityResolver:

public interface IEntityResolver
    {
        Task<long> ResolveAsync<TEntity>(string entityId)
            where TEntity : BaseEntity, IHasEntityIdEntity;
    }

Apparently, there's nothing wrong with the definition of the interfaces and their usages since stopping the container throwing the exceptions and starting a new one works most of the time. Also, such methods are used very frequently in our application from all containers.

I've been thinking to catch this exception and add some more info to the logs, but I'm not sure if we would be able to get something useful out of them.

In the meanwhile, does anyone have any ideas on how to track this down? Does anyone else experience this? Does anyone have an idea what could be the issue?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions