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

Add attributes to class & properties on the fly

Is there anything in castle that can let me add attributes to a class on the fly? I have a dto in a project that I want to use as a data contract in a wcf service. I'd need to add a [DataContract] attribute to the class and then [DataMember] to…
user156888
2
votes
1 answer

Can a C# attribute add a parameter to a method?

I found this question - which is very similar to what I'm attempting. However, my use case is a little different. We have the need to store audit history for business services. However, we need to be able to manually call audit checkpoints during…
user677526
2
votes
1 answer

Managed Extensibility Framework, Interception and Dynamic Proxy

easy task, but couldn't find any direction. i want to intercept object creation of MEF and return proxy (using castle dynamic proxy) of my object either then the object itself. is it possible to do that?
ktutnik
  • 6,882
  • 1
  • 29
  • 34
2
votes
2 answers

How to "really" down-cast a DynamicProxy back to its original type (to send over WCF)

OK, the situation is we have a class, PatientDto, and a DynamicProxy generated by Castle, PatientDtoProxy. We're using this proxy in the Silverlight client, then want to send it back to the server via a WCF service call. The WCF service Contract…
Bobby
  • 1,666
  • 3
  • 16
  • 27
2
votes
1 answer

Datacontact for Castle.Proxies.EntityProxy failed

How to send Castle.Proxies.EntityProxy via WCF Channel? How to set the proxy as KnownType?
Hans
  • 21
  • 1
2
votes
1 answer

Sitecore, GlassMapper, Interfaces and Dynamic Proxies

In Sitecore, I Have 2 classes representing 2 possible nodes that can live as children of another node. My model contains a Children property which is an IEnumerable (INode being implemented by both classes). At runtime, I get the underlying…
Hellraiser
  • 579
  • 7
  • 18
2
votes
2 answers

Event Interception with Castle DynamicProxy

In googling I can't seem to find an example of intercepting event on a proxied type and it doesn't seem to be working for me. Is there a way I can do this (ie. use an IInterceptor when an event is invoked)?
Jeff
  • 35,755
  • 15
  • 108
  • 220
2
votes
1 answer

Can I specify to Castle Windsor which virtual methods to override in a class proxy?

I have many virtual methods in a class, but only one should be intercepted, Can I tell Castle Windsor to override only that method so I dont have to do validation in the Intercept method? Edit: I use the IKernelEvents.ComponentRegistered event to…
Thiago Padilha
  • 4,590
  • 5
  • 44
  • 69
2
votes
4 answers

How can I write Interceptor (AOP) with Castle Core or Other libraries (just free libraries) for Cross Cutting Concerns

I want to have an attribute like this for Cross Cutting Concerns like Logging , Exception , ... public class MyService { [Log] // Interception (AOP) [ExceptionHandler] // Interception (AOP) public void DoSomething() { } } I know that I can…
hhh fff
  • 21
  • 1
  • 2
2
votes
1 answer

MethodAccessException when calling nlog LogManager.GetCurrentClassLogger()

I'm getting an exception when I run a unit test on a controller in web project (ASP.NET web api). The exception is thrown when LogManager.GetCurrentClassLogger() of the controller is executed: System.MethodAccessException: Attempt by method…
Boris Lipschitz
  • 9,236
  • 5
  • 53
  • 63
2
votes
2 answers

Selectively intercepting methods using autofac and dynamicproxy2

I'm currently doing a bit of experimenting using Autofac-1.4.5.676, autofac contrib and castle DynamicProxy2. The goal is to create a coarse-grained profiler that can intercept calls to specific methods of a particular interface. The problem: I…
Mark Simpson
  • 23,245
  • 2
  • 44
  • 44
2
votes
2 answers

Castle dynamic proxy object to original object convertion

ProxyGenerator generator = new ProxyGenerator(); var interceptor = new StandardInterceptor(); MyInterfaceImpl test = (MyInterfaceImpl)generator.CreateClassProxy(typeof(MyInterfaceImpl), interceptor); In above example, test object is proxy…
amar kumar
  • 31
  • 2
2
votes
0 answers

System.Linq.Dynamic: Could not load file or assembly Castle.DynamicProxy2

I have three .NET 4.5 projects Example.Mvc (Mvc 5), Example.UnitTest, Example.Data. I loaded Dynamic Linq Library v1.1.13 from NuGet into my data layer "Example.Data" project. Example.Data uses Entity Framework 6 in which I would like to use the…
jaybro
  • 1,363
  • 1
  • 12
  • 23
2
votes
1 answer

Transparent lazy loading with PetaPoco

I have used NHibernate in previous enterprise applications but its complex setup and scattered documentation are pushing me to try to use the much simpler PetaPoco in my next application. The main issue I am facing is the implementation of…
JimmyTheOne
  • 233
  • 2
  • 13
2
votes
1 answer

Castle Dynamic Proxy in Windsor Container

I've got a bit of a problem. I'm working in the Castle Windsor IOC Container. Now what i wanted to do is just mess about with some AOP principles and what i specifically want to do is based on a method name perform some logging. I have been looking…
Iffy
  • 219
  • 3
  • 15