Feature Comparison: Castle DynamicProxy vs AspectCore Framework

July 20, 2026 ยท View on GitHub

This document provides a factual comparison of interception and proxy capabilities between Castle DynamicProxy (v5.2.1) and AspectCore Framework.

Core Interception

FeatureCastle DynamicProxyAspectCore
Sync method interceptionYesYes
Async Task<T> interceptionPartial (requires IAsyncInterceptor wrapper)Yes (native)
Async ValueTask<T> interceptionNoYes
IAsyncEnumerable<T> interceptionNoYes
Unified interceptor model (sync + async)No (separate IInterceptor / IAsyncInterceptor)Yes

Modern C# Language Features

FeatureCastle DynamicProxyAspectCore
ref / ref readonly return valuesNoYes
Record type proxy generationNoYes
Primary constructors (C# 12)NoYes
Partial properties (C# 13)NoYes
Default interface methodsPartialYes

Compilation and AOT

FeatureCastle DynamicProxyAspectCore
NativeAOT supportNoYes (Source Generator)
Compile-time proxy generationNo (planned v6, no release date)Yes
Runtime IL emission (Reflection.Emit)Yes (only option)Yes (DynamicProxy engine)
Source Generator engineNoYes
Trimming-safeNoYes (Source Generator)

Dependency Injection Integration

FeatureCastle DynamicProxyAspectCore
Microsoft.Extensions.DependencyInjection nativeNo (needs Autofac or Windsor bridge)Yes
Keyed service interception (.NET 8+)NoYes
IServiceProviderFactory<T> integrationNo (container-specific)Yes
ASP.NET Core IHost integrationNo (manual setup)Yes (AddDynamicProxy())

Interceptor Configuration

FeatureCastle DynamicProxyAspectCore
Attribute-based interceptor selectionLimited (InterceptorAttribute)Yes (AbstractInterceptorAttribute)
Predicate-based global configurationNo (manual IInterceptorSelector)Yes (AspectPredicate)
Non-aspect exclusion (opt-out)LimitedYes ([NonAspect])
Interceptor orderingBy registration orderYes (explicit Order property)
Inherited interception controlLimitedYes (Inherited property)

Proxy Generation

FeatureCastle DynamicProxyAspectCore
Interface proxy (with target)YesYes
Class proxy (virtual methods)YesYes
Mixin supportYesNo
IChangeProxyTargetYesNo
Multiple interface proxyYesYes

Performance Characteristics

AspectCastle DynamicProxyAspectCore
First-call latencyHigher (runtime IL gen)Lower (Source Generator pre-compiled)
Steady-state overheadModerateLow
Per-invocation allocationHigherLower
Startup time impactHigher (assembly scanning + emit)Minimal (Source Generator)

Note: See benchmarks/AspectCore.Benchmarks.Competitive/ for reproducible numbers.

Ecosystem

FeatureCastle DynamicProxyAspectCore
Castle Windsor integrationNativeVia AspectCore.Extensions.Windsor
Autofac integrationVia Autofac.Extras.DynamicProxyVia AspectCore.Extensions.Autofac
LightInject integrationNoYes
NuGet downloads (monthly)~2M~200K
Active maintenanceLimited (v5.2.1, Feb 2024)Active
.NET 9/10 supportPartialFull
LicenseApache 2.0MIT

Migration Compatibility

ScenarioSupport
Run Castle interceptors in AspectCore pipelineYes (via CastleInterceptorAdapter)
Run AspectCore interceptors in Castle pipelineYes (via AspectCoreInterceptorAdapter)
Gradual migration (both frameworks coexist)Yes
Zero-change migrationNo (API differences require code changes)

Summary

AspectCore provides broader language feature coverage, native async support, NativeAOT compatibility, and tighter MSDI integration compared to Castle DynamicProxy.

Castle DynamicProxy offers mixin support and larger ecosystem adoption but lacks modern C# feature support and has no NativeAOT path.

For new projects or projects targeting .NET 8+, AspectCore is the recommended choice. For existing Castle/Windsor codebases, the AspectCore.Extensions.CastleCompat package provides a gradual migration path.