<PackageReference Include="Castle.Core" Version="3.0.0.2001" />

CompositionInvocation

public abstract class CompositionInvocation : AbstractInvocation
using System; using System.Reflection; namespace Castle.DynamicProxy.Internal { public abstract class CompositionInvocation : AbstractInvocation { protected object target; public override object InvocationTarget => target; public override MethodInfo MethodInvocationTarget => InvocationHelper.GetMethodOnObject(target, base.Method); public override Type TargetType => GetTargetType(target); protected CompositionInvocation(object target, object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, object[] arguments) : base(proxy, interceptors, proxiedMethod, arguments) { get; } protected CompositionInvocation(object target, object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, object[] arguments, IInterceptorSelector selector, ref IInterceptor[] methodInterceptors) : base(proxy, GetTargetType(target), interceptors, proxiedMethod, arguments, selector, ref methodInterceptors) { get; } protected void EnsureValidProxyTarget(object newTarget) { if (newTarget == null) throw new ArgumentNullException("newTarget"); if (!object.ReferenceEquals(newTarget, proxyObject)) return; string message = "This is a DynamicProxy2 error: target of proxy has been set to the proxy itself. This would result in recursively calling proxy methods over and over again until stack overflow, which may destabilize your program.This usually signifies a bug in the calling code. Make sure no interceptor sets proxy as its own target."; throw new InvalidOperationException(message); } protected void EnsureValidTarget() { if (target == null) ThrowOnNoTarget(); if (!object.ReferenceEquals(target, proxyObject)) return; string message = "This is a DynamicProxy2 error: target of invocation has been set to the proxy itself. This may result in recursively calling the method over and over again until stack overflow, which may destabilize your program.This usually signifies a bug in the calling code. Make sure no interceptor sets proxy as its invocation target."; throw new InvalidOperationException(message); } private static Type GetTargetType(object targetObject) { return targetObject?.GetType(); } } }