MassiveDynamicProxyGenerator 1.3.0-preview1

.NET Standard 1.4 .NET Framework 4.0
This is a prerelease version of MassiveDynamicProxyGenerator.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MassiveDynamicProxyGenerator --version 1.3.0-preview1
NuGet\Install-Package MassiveDynamicProxyGenerator -Version 1.3.0-preview1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MassiveDynamicProxyGenerator" Version="1.3.0-preview1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MassiveDynamicProxyGenerator --version 1.3.0-preview1
#r "nuget: MassiveDynamicProxyGenerator, 1.3.0-preview1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MassiveDynamicProxyGenerator as a Cake Addin
#addin nuget:?package=MassiveDynamicProxyGenerator&version=1.3.0-preview1&prerelease

// Install MassiveDynamicProxyGenerator as a Cake Tool
#tool nuget:?package=MassiveDynamicProxyGenerator&version=1.3.0-preview1&prerelease


.Net library for generate proxy class instances

Massive Dynamic Proxy Generator is a library for generating lightweight .NET proxies on the fly at runtime. Proxy objects allow calls to members of an object to be intercepted without modifying the code of the class. Both classes and interfaces can be proxied, however only virtual members can be intercepted.


  • Proxy instance generator, for intercept.
  • Decorator generator.
  • Proxy instance generator, for control instancing real implementation (e.g. lazy loading).

The following platforms are supported:

  • .Net 4.0, 4.5, 4.6, 4.6.1, NetStandard 1.6, NetStandard 2.0 and UWP applications (NetStandard 1.4)

Generate decorator

 ProxyGenerator generator = new ProxyGenerator();
 Calculator realInstance = new Calculator();
 ICallableInterceptor interceptor = new CallableInterceptorAdapter((invocation) =>
     Console.WriteLine(" Log: Call method {0}", invocation.MethodName);
         Console.WriteLine(" Log: return: {0}", invocation.ReturnValue ?? "null");
     catch(Exception ex)
         Console.WriteLine(" Log: Exception message: {0}", ex.Message);

 ICalculator decorator = generator.GenerateDecorator<ICalculator>(interceptor, realInstance);

 Console.WriteLine("Before call Add with 2013 and 6");
 int result = decorator.Add(2013, 6);
 Console.WriteLine("Result is {0}", result);

Generate proxy

IInterceptor jsonRpcInterceptor = new InterceptorAdapter((invocation, isDynamic) =>
    Guid requestId = Guid.NewGuid();
    var rcpBody = new
        jsonrpc = "2.0",
        method = invocation.MethodName,
        @params = invocation.Arguments,
        id = requestId.ToString()

    string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(rcpBody);

    //simulate sending and recrive

    Console.WriteLine(" Sending Rpc: {0}", serialized);
    string recText = $"{{\"jsonrpc\": \"2.0\", \"result\": 19, \"id\": \"{requestId.ToString()}\"}}";
    Console.WriteLine(" Rec Rpc: {0}", recText);

    Newtonsoft.Json.Linq.JObject response = Newtonsoft.Json.JsonConvert.DeserializeObject< Newtonsoft.Json.Linq.JObject>(recText);
    invocation.ReturnValue = response["result"].ToObject(invocation.ReturnType);

ProxyGenerator generator = new ProxyGenerator();

ICalculator calcilator = generator.GenerateProxy<ICalculator>(jsonRpcInterceptor);

int resultModulo = calcilator.Modulo(15, 4);

Console.WriteLine("Modulo 15 and 4 is {0}", resultModulo);

int resultProduct = calcilator.Product(8, 486);

Console.WriteLine("Product 8 and 486 is {0}", resultProduct);

Generate instance proxy

IInstanceProvicer instanceProvider = new LazyInstanceProvider<ICalculator>(
    () =>
        Console.WriteLine(" Log: Create Calculator.");
        return new Calculator();
    }, false);

ProxyGenerator generator = new ProxyGenerator();
ICalculator  calculator = generator.GenerateInstanceProxy<ICalculator>(instanceProvider);

Console.WriteLine("Before call Add with 2013 and 6");
int result = calculator.Add(2013, 6);
Console.WriteLine("Result is {0}", result);

Console.WriteLine("Before call Product with 2013 and 6");
int result2 = calculator.Product(2013, 6);
Console.WriteLine("Result is {0}", result2);
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on MassiveDynamicProxyGenerator:

Package Downloads

MassiveDynamicProxyGenerator.SimpleInjector is library of extensions method for IoC container - Simple Injector. Adding methods for register mock implementations, proxys, instance proxies for resolving circular depndencies or lazy initialization and interpetion for decoration instances.


A type-safe REST library


MassiveDynamicProxyGenerator Microsoft.Extensions.DependencyInjection is intergration MassiveDynamicProxyGenerator to standard IoC container in ASP.NET Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 12,190 11/24/2020
1.4.0 4,278 8/27/2019
1.3.0 3,218 7/10/2018
1.3.0-preview1 959 5/8/2018
1.2.2 1,219 4/14/2018
1.2.1 1,228 8/21/2017
1.2.0 1,267 6/28/2017
1.2.0-beta1 1,058 6/13/2017
1.1.0 1,171 3/22/2017
1.0.0 1,186 12/1/2016

Change interface IInvocation.
Add universal async ibterceptor CallableInterceptorAsyncAdapter as abstract class for handle error in async task.
Add support for .Net Stdard 2.0.

Fix typo error ProxygGenerator -> ProxyGenerator.