System.Reflection.DispatchProxy
4.8.2
Prefix Reserved
dotnet add package System.Reflection.DispatchProxy --version 4.8.2
NuGet\Install-Package System.Reflection.DispatchProxy -Version 4.8.2
<PackageReference Include="System.Reflection.DispatchProxy" Version="4.8.2" />
<PackageVersion Include="System.Reflection.DispatchProxy" Version="4.8.2" />
<PackageReference Include="System.Reflection.DispatchProxy" />
paket add System.Reflection.DispatchProxy --version 4.8.2
#r "nuget: System.Reflection.DispatchProxy, 4.8.2"
#:package System.Reflection.DispatchProxy@4.8.2
#addin nuget:?package=System.Reflection.DispatchProxy&version=4.8.2
#tool nuget:?package=System.Reflection.DispatchProxy&version=4.8.2
About
Provides a DispatchProxy class to dynamically create proxy instances that implement a specified interface.
Key Features
Method invocations on a generated proxy instance are dispatched to a Invoke() method. Having a single invoke method allows centralized handling for scenarios such as logging, error handling and caching.
How to Use
Create the proxy class that derives from DispatchProxy, override Invoke() and call one of the static DispatchProxy.Create() methods to generate the proxy type.
The example below intercepts calls to the ICallMe interface and logs them.
class Program
{
static void Main(string[] args)
{
ICallMe proxy = LoggingDispatchProxy.Create<ICallMe>(new MyClass());
proxy.CallMe("Hello!");
}
}
public interface ICallMe
{
void CallMe(string name);
}
public class MyClass : ICallMe
{
public void CallMe(string message)
{
Console.WriteLine($"Inside the called method with input '{message}'");
}
}
public class LoggingDispatchProxy : DispatchProxy
{
private ICallMe _target;
protected override object Invoke(MethodInfo targetMethod, object[] args)
{
Console.WriteLine($"Calling method: '{targetMethod.Name}' with arguments: '{string.Join(", ", args)}'");
object result = targetMethod.Invoke(_target, args);
Console.WriteLine($"Called method: '{targetMethod.Name}'.");
return result;
}
public static T Create<T>(T target) where T : class
{
LoggingDispatchProxy proxy = DispatchProxy.Create<T, LoggingDispatchProxy>() as LoggingDispatchProxy;
proxy._target = (ICallMe)target;
return proxy as T;
}
}
Main Types
The main types provided by this library are:
- System.Reflection.DispatchProxy
Additional Documentation
- API reference can be found in: https://learn.microsoft.com/en-us/dotnet/api/system.reflection.dispatchproxy
License
System.Reflection.DispatchProxy is released as open source under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 2.0
- No dependencies.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- System.Reflection.Emit (>= 4.7.0)
-
.NETStandard 2.1
- No dependencies.
NuGet packages (164)
Showing the top 5 NuGet packages that depend on System.Reflection.DispatchProxy:
| Package | Downloads |
|---|---|
|
System.Private.ServiceModel
Package Description |
|
|
CoreWCF.Primitives
CoreWCF is a port of the service side of Windows Communication Foundation (WCF) to .NET Core. The goal of this project is to enable existing WCF services to move to .NET Core. |
|
|
CoreWCF.Http
CoreWCF is a port of the service side of Windows Communication Foundation (WCF) to .NET Core. The goal of this project is to enable existing WCF services to move to .NET Core. |
|
|
Microsoft.NETCore
Provides a set of packages that can be used when building portable libraries on .NETCore based platforms. \r\n TFS ID: 1599443, GitHub SHA: https://github.com/dotnet/corefx/tree/eede273a4dfabcea608621f5e1bbf8ad00584cfb |
|
|
CoreWCF.NetTcp
CoreWCF is a port of the service side of Windows Communication Foundation (WCF) to .NET Core. The goal of this project is to enable existing WCF services to move to .NET Core. |
GitHub repositories (11)
Showing the top 11 popular GitHub repositories that depend on System.Reflection.DispatchProxy:
| Repository | Stars |
|---|---|
|
dotnet/wcf
This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
|
|
|
CoreWCF/CoreWCF
Main repository for the Core WCF project
|
|
|
RRQM/TouchSocket
TouchSocket is an integrated .NET networking framework that includes modules for socket, TCP, UDP, SSL, named pipes, HTTP, WebSocket, RPC, and more. It offers a one-stop solution for TCP packet issues and enables quick implementation of custom data message parsing using protocol templates.
|
|
|
malware-dev/MDK-SE
Malware's Development Kit for SE
|
|
|
open-telemetry/opentelemetry-dotnet-contrib
This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
|
|
|
Code-Sharp/WampSharp
A C# implementation of WAMP (The Web Application Messaging Protocol)
|
|
|
DevrexLabs/memstate
In-memory event-sourced ACID-transactional distributed object graph engine for .NET Standard
|
|
|
jacqueskang/IpcServiceFramework
.NET Core Inter-process communication framework
|
|
|
hikalkan/scs
TCP Server/Client Communication and RMI Framework
|
|
|
beetlex-io/BeetleX-Samples
BeetleX micro services framework (tcp webapi websocket and xrpc) samples
|
|
|
zzzprojects/EntityFramework-Classic
Entity Framework Classic is a supported version of the latest EF6 codebase. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.8.2 | 304,676 | 3/19/2025 |
| 4.8.0 | 317,098 | 11/12/2024 |
| 4.7.1 | 173,930,603 | 5/12/2020 |
| 4.7.0 | 1,256,927 | 12/3/2019 |
| 4.7.0-preview3.19551.4 | 965 | 11/13/2019 |
| 4.7.0-preview2.19523.17 | 946 | 11/1/2019 |
| 4.7.0-preview1.19504.10 | 962 | 10/15/2019 |
| 4.6.0 | 782,201 | 9/23/2019 |
| 4.6.0-rc1.19456.4 | 990 | 9/16/2019 |
| 4.6.0-preview9.19421.4 | 1,093 | 9/4/2019 |
| 4.6.0-preview9.19416.11 | 916 | 9/4/2019 |
| 4.6.0-preview8.19405.3 | 1,091 | 8/13/2019 |
| 4.6.0-preview7.19362.9 | 1,004 | 7/23/2019 |
| 4.6.0-preview6.19303.8 | 2,945 | 6/12/2019 |
| 4.6.0-preview6.19264.9 | 953 | 9/4/2019 |
| 4.6.0-preview5.19224.8 | 1,216 | 5/6/2019 |
| 4.6.0-preview4.19212.13 | 1,036 | 4/18/2019 |
| 4.6.0-preview3.19128.7 | 1,059 | 3/6/2019 |
| 4.6.0-preview.19073.11 | 1,153 | 1/29/2019 |
| 4.6.0-preview.18571.3 | 1,196 | 12/3/2018 |
| 4.5.1 | 4,874,165 | 6/18/2018 |
| 4.5.0 | 177,916,881 | 5/29/2018 |
| 4.5.0-rc1 | 4,250,746 | 5/6/2018 |
| 4.5.0-preview2-26406-04 | 235,439 | 4/10/2018 |
| 4.5.0-preview1-26216-02 | 45,175 | 2/26/2018 |
| 4.4.0 | 60,009,282 | 8/11/2017 |
| 4.4.0-preview2-25405-01 | 18,532 | 6/27/2017 |
| 4.4.0-preview1-25305-02 | 108,669 | 5/9/2017 |
| 4.3.0 | 43,091,779 | 11/15/2016 |
| 4.3.0-preview1-24530-04 | 53,375 | 10/24/2016 |
| 4.0.1 | 104,886,413 | 6/27/2016 |
| 4.0.1-rc2-24027 | 2,113,045 | 5/16/2016 |
| 4.0.1-beta-23516 | 23,146 | 11/18/2015 |
| 4.0.1-beta-23409 | 5,205 | 10/15/2015 |
| 4.0.1-beta-23225 | 155,358 | 9/2/2015 |
| 4.0.0 | 1,580,113 | 7/29/2015 |
| 4.0.0-beta-23109 | 4,253 | 7/27/2015 |
| 4.0.0-beta-23019 | 4,489 | 6/30/2015 |
| 4.0.0-beta-22816 | 4,533 | 4/24/2015 |