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
0
votes
1 answer

migration from asp.core 2.2 to 3.1. Autofac.Core.DependencyResolutionException

I am doing a migration and have encountered an exception. Autofac can resolve my service from an instance of a service provider, but cannot get it in my controller at the time of the request. Exception: Castle.DynamicProxy.ProxyGe …
Vlad
  • 193
  • 2
  • 14
0
votes
1 answer

Castle Dynamic Proxy MixinInstance behaviour

I was struggling with non virtual members in my POCO classes using Castle's DynamicProxy generator and hit upon a way to make this happen using the ProxyGenerationOptions.AddMixinInstance() using the below code. The question I have is why, if the…
Geoff Scott
  • 897
  • 1
  • 10
  • 17
0
votes
1 answer

Is Castle Dynamic Proxy IInvocation really different in .net Core and Framework?

I have code that uses Castle DynamicProxy to proxy code invocation. In Intercept(IInvocation invocation), I use NewtonSoft to Json serialize the invocation. Newtonsoft.Json.JsonConvert.SerializeObject(invocation.Method); In Framework this…
0
votes
2 answers

How to intercept an IInvocation using dynamic proxy?

Is it possible to intercept an IInvocation using dynamic proxy and windsor (if windsor is even needed for such a case. I am using it to configure the proxy generation though)? I would like to log that an interception has changed the call to the…
the_drow
  • 18,571
  • 25
  • 126
  • 193
0
votes
1 answer

Sort an array using Castle.DynamicProxy in C#

I am trying to learn AOP. I have a method returning array. public class ReturnCollection { public virtual Array ReturnArrayStringData() { string[] IntArray = { "1", "a", "4", "'", "&", "g" }; foreach (var item in IntArray) …
ImC0der
  • 308
  • 2
  • 18
0
votes
2 answers

How to replace c# ToString() method at runtime

How to implement an extension method that can change result of ToString() of any object? What I have now: public class ProxyBase { public override string ToString() { return "hardcodedValue" } } public static T…
user963935
  • 493
  • 4
  • 20
0
votes
1 answer

Is it possible to intercept a constructor call with dynamic proxy?

Is it possible to intercept a constructor call with dynamic proxy? I registered a proxy on a class that only contains a constructor as a test but it's not intercepted. I am guessing that it's currently not possible but maybe there's something…
the_drow
  • 18,571
  • 25
  • 126
  • 193
0
votes
1 answer

Selecting an interceptor based on a facility created ILogger

I have two types of interceptors: LoggingWithDebugInterceptor and LoggingInterceptor. I am using the Castle Logging Facility and I am wondering how to write a selector that registers an interceptor on my container for any type that implements…
the_drow
  • 18,571
  • 25
  • 126
  • 193
0
votes
0 answers

Can Castle DynamicProxy be configured to not write to 'ref' args?

I'm hitting an AccessViolationException when trying to use an interface proxy that is wrapping a third-party interface. The exception is being thrown when the emitted code writes the invocation arg array back to the original arg for a 'ref' type…
Ben Ruthig
  • 11
  • 1
0
votes
0 answers

How to get the name of an element that invoked an action using IInterceptor from Castle.DynamicProxy

Pretty much what I'm trying to do is an aspect using the IInterceptor interface from the Castle.DynamicProxy namespace for logging certain element actions and save them to a file. The implementation I have looks as describe below. The interface type…
Carlos Parra
  • 957
  • 9
  • 19
0
votes
2 answers

AsyncInterceptor with Polly (AOP retry style)

For some part of my system I need to add retry logic for reading from the database. I have a number of repositories with async and sync read methods that I can't change. I found a simple solution - interception of all read methods with…
0
votes
1 answer

UWP with Castle.Core: Compile with .NET Native tool chain error

In our UWP App when building the app with .NET Native tool chain activated, we get the following error: Exception thrown: 'System.Exception' in Castle.Core.dll An exception of type 'System.Exception' occurred in Castle.Core.dll but was not handled…
Peter Wyss
  • 395
  • 2
  • 16
0
votes
1 answer

Autofac EnableInterfaceInterceptors Error

We updating to Autofac 2.4.4 after moving up to MVC3 and are receiving an exception when we include EnableInterfaceInterceptors on our registration. The exception does not appear until DependencyResolver.Current.GetService() is…
Thad
  • 1,518
  • 2
  • 21
  • 37
0
votes
1 answer

Can static methods be intercepted with Castle DynamicProxy?

Can static methods be intercepted with Castle DynamicProxy? And if so, how?
SteveC
  • 15,808
  • 23
  • 102
  • 173
0
votes
0 answers

AutoMoq to respect MaxLengthAttribute

I'm using AutoFixture with AutoMoq to generate and configure a Mock to an interface. This interface uses the MaxLength attribute to specify the maximum length each property. How can I make the generated mock respect the MaxLength attribute. Please,…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185