Questions tagged [castle-dynamicproxy]

Castle DynamicProxy 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.

Castle DynamicProxy 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.

Resources

335 questions
68
votes
1 answer

Castle DynamicProxy - Failure when creating proxy involving a GTP used as a GTR

OK, now I'm really confused. I originally had this problem, which is, according to posters, an issue with the version of Castle.DynamicProxy that's ILMerged into the latest Rhino.Mocks library. It has, according to several authorities on the…
KeithS
  • 70,210
  • 21
  • 112
  • 164
33
votes
8 answers

Intercept the call to an async method using DynamicProxy

Below is the code from the Intercept method on a custom type that implements IInterceptor of the Castle Dynamic Proxy library. This snippet is from an AOP based logging proof-of-concept console app that is posted here. public void…
Hari Pachuveetil
  • 10,294
  • 3
  • 45
  • 68
31
votes
3 answers

What are the differences between LinFu.DynamicProxy and Castle.DynamicProxy?

I am looking at adding logic to a library I am working on that would require the need for a Dynamic Proxy. I would like to get some advice from user's who have used these two library's in a production environment. Does one out perform the other,…
Dale Ragan
  • 18,202
  • 3
  • 54
  • 70
28
votes
5 answers

Intercept async method that returns generic Task<> via DynamicProxy

My questions is related to this post Intercept the call to an async method using DynamicProxy I want to implement interceptor that works with async methods that returns Task or Task result. I use next code for return ContinueWith result (in…
Anatoliy
  • 672
  • 5
  • 12
23
votes
3 answers

How use IInterceptor in Castle.DynamicProxy?

I wrote an example like this Simple Calculator class : public class Calculator { public int Add(int a, int b) { return a + b; } } implemented "IInterceptor" that provided by DynamicProxy [Serializable] public abstract class…
19
votes
2 answers

What really interceptors do with my c# class?

I was asked to implement castle dynamic proxy in my asp.net web application and i was going through couple of articles which i got from Castle Project and Code Project about castle dynamic proxy in asp.net web application.... Both articles delt…
ACP
  • 34,682
  • 100
  • 231
  • 371
17
votes
2 answers

Getting underlying type of a proxy object

I'm using Castle DynamicProxy and my ViewModels are a proxy, something like this: namespace MyApplication.ViewModels { public class MyViewModel : BaseViewModel, IMyViewModel { } } a proxy of my viewmodel looks like this though: {Name =…
Hadi Eskandari
  • 25,575
  • 8
  • 51
  • 65
16
votes
1 answer

Castle Dynamic Proxy not intercepting method calls when invoked from within the class

I have run into a bit of (what I think is) strange behaviour when using Castle's Dynamic Proxy. With the following code: class Program { static void Main(string[] args) { var c = new InterceptedClass(); var i = new…
13
votes
2 answers

Applying Aspect Oriented Programming

I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc. My solution has revolved around Castle Windsor and DynamicProxy because I can apply everything using a Boo based DSL and keep my code…
Chris Canal
  • 4,824
  • 9
  • 35
  • 45
12
votes
2 answers

Why won't DynamicProxy's interceptor get called for *each* virtual method call?

An example explains it best : public interface IA { void foo(); void bar(); } public class A : IA { public virtual void foo(){ Console.Write("foo"); bar(); //call virtual method } public virtual void bar(){ …
Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233
12
votes
2 answers

Whats the difference between PostSharp and Castle Dynamic Proxy?

Just wondering what the main differences are between these libraries, how they differ in features and functionality. Hoping for more information than I could find with a Google query...
John Farrell
  • 24,673
  • 10
  • 77
  • 110
10
votes
2 answers

Castle DynamicProxy : How to Proxy Equals when proxying an interface?

I need to use Castle DynamicProxy to proxy an interface by providing an instance of it to ProxyGenerator.CreateInterfaceProxyWithTarget. I also need to make sure that calls to Equals, GetHashCode and ToString hits the methods on the concrete…
driis
  • 161,458
  • 45
  • 265
  • 341
10
votes
1 answer

Using Simple Injector with Castle Proxy Interceptor

I'm using Simple Injector in my asp.net mvc 4 project. I can't figure out how can I use Simple Injector with castle proxy interceptor.
10
votes
4 answers

Castle DynamicProxy: Get unproxied object

I'm using Castle DynamicProxy to add an interceptor to my types. Now I need to get the underlying base type (NOT the proxy itself). I found a few hints on SO that suggested to use the ProxyUtil class like this: object realInstance =…
cguedel
  • 1,092
  • 1
  • 14
  • 28
9
votes
1 answer

Is it possible to create an async inteceptor using Castle.DynamicProxy?

We basically have a class that looks like this below that is using the Castle.DynamicProxy for Interception. using System; using System.Collections.Concurrent; using System.Reflection; using System.Threading; using System.Threading.Tasks; using…
Eric Renken
  • 91
  • 1
  • 3
1
2 3
22 23