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
3
votes
3 answers

Why am I getting Interceptor attempted to ‘Proceed’ for a method without a target error?

In my case I have main project and test project. I was getting proper results on the test project where I have only one Installer class and register everything in one place. In my main project I had several installers (one for service, one for…
Falcon
  • 650
  • 1
  • 8
  • 24
3
votes
1 answer

Using Castle Dynamic Proxy with WebApi Controllers

I am trying to implement AOP logging using castle's dynamic proxy library in a .net MVC 4 application. We are using structure map for our dependency injection. I have successfully set up AOP logging for our standard normal MVC controllers, but we…
Simon
  • 415
  • 1
  • 4
  • 15
3
votes
3 answers

Do DynamicProxy classes work well with intellisense/type safety?

I was looking at using DynamicProxy classes, and I'm fairly new to this concept. Before I got too far down this road, I was wondering how well these classes work with IntelliSense and type safety? I'm just afraid of using something like Castle…
michael
  • 14,844
  • 28
  • 89
  • 177
3
votes
2 answers

Using dynamic proxy on NHibernate objects

I'm trying to use Castle.DynamicProxy2 to cleanup code within NHibernate persisted classes. Here is a simple version of it. The Pet class: public class Pet { public int Id { get; set; } public string Name { get; set; } public int Age {…
ca7l0s
  • 71
  • 1
  • 7
3
votes
1 answer

Castle DynamicProxy - 'classToProxy' must be a class

I am probably missing something extremely simple. I am just trying to write a very minimalistic example of usage of DynamicProxy - I basically want to intercept the call and display method name and parameter value. I have code as follows: public…
Sebastian K
  • 6,235
  • 1
  • 43
  • 67
3
votes
1 answer

Castle Windsor: How to retrieve proxy for specific instance?

I'm using Castle Windsor in my project. Some registered components are intercepted. Because the components are registered through interfaces, Castle Windsor creates interface proxies (Castle Windsor creates a standalone type which implements the…
Oliver Hanappi
  • 12,046
  • 7
  • 51
  • 68
3
votes
1 answer

How to write interceptor for methods returning IEnumerable

I wrote simple interceptor (with Castle.DynamicProxy) to handle database connection life cycle. I.e. all services have Connection property which opens new one on first use. Connection is being closed automatically after each method call: class…
orientman
  • 31
  • 3
2
votes
1 answer

Calls to properties inside non-intercepted methods are not forwarded to target object

I have a change tracking framework that tracks changed made to domain objects on the client. It uses Castle.Windsor as the tool for creating proxy objects. After I changed Castle to version 3.0 calls of properties inside methods that are not…
Antineutrino
  • 1,093
  • 3
  • 10
  • 26
2
votes
3 answers

Turn off signing for Castle DynamicProxy

I am having problems when trying to use a TypedFactoryFacility in Castle. I'm using Castle v3.0.0 and I've created a ViewFactory, using injector.AddFacility(Of TypedFactoryFacility)() and: container.Register(CMR.Component.For(Of…
Rich
  • 3,640
  • 3
  • 20
  • 24
2
votes
2 answers

Castle DynamicProxy2: Get the Target inside an Interceptor?

I'm using Castle DynamicProxy2 to "tack on" interfaces to retrieve fields from a dictionary. For example, given the following class: public class DataContainer : IDataContainer { private Dictionary _Fields = null; public…
Jordan
  • 2,811
  • 2
  • 20
  • 21
2
votes
1 answer

CastleDynamic proxy: NullReferenceException when calling method of a proxy

I'm using StructureMap to have an instance of an interface and I wrap it into a proxy with Castle DynamicProxy: var proxy = generator.CreateInterfaceProxyWithTarget( ObjectFactory.GetInstance() , new SwitchInterceptor(isGranted,…
JiBéDoublevé
  • 4,124
  • 4
  • 36
  • 57
2
votes
1 answer

Why no IChangeProxyTarget on IInvocation instances generated by ProxyGenerator.CreateClassProxyTypeWithTarget via InheritanceInvocationTypeGenerator?

Is it by design to prevent changing the proxy target for concrete types? If so, why? Background: I have a concrete class that I want to proxy. Further, I want to replace the target of the proxy at some point in the workflow. I've attempted to use…
codekaizen
  • 26,990
  • 7
  • 84
  • 140
2
votes
1 answer

method selector on one of many interceptors for a service registered in Castle.Windsor

Using Castle.Windsor, how would I go about adding a IProxyGenerationHook or selector for one of several interceptors defined for a specific service. For example consider the following component registration: container.Register( _ …
2
votes
1 answer

Moq + Castle Dynamic Proxy - exception mocking nested generic interfaces

I'm receiving an argument exception from Castle Dynamic Proxy, while using Moq to create a mock of object that is implementing a nested generic interface with generic method that has an interface constraint. The exception is:…
Cortlendt
  • 2,190
  • 4
  • 29
  • 50
2
votes
1 answer

Castly Dynamic Proxy - Get the target method's return value

When proxying an object and intercepting a method using castle dynamic proxy, is it possible to get the return value of the target method? I have tried using the following methods, object result = invocation.GetConcreteMethod().Invoke(instance,…
Sean Thoman
  • 7,429
  • 6
  • 56
  • 103