castle-dynamicproxy

can you use castle dynamic proxies on web services references?

Hi, Is it possible to create a dynamic proxy on the a web service reference that has been added to a visual studio project? I've added the web service reference in the normal way and tried to create a dynamic proxy using castle to wrap the method invocation in a try/catch to translate any SoapExceptions, but on running it I'm getting a ...

help building castle dynamic proxy

So I pulled the source from https://svn.castleproject.org/svn/castle/DynamicProxy/trunk/ Open it up in vs.net 2008 problems: vs.net can't open the assembly.cs assembly signing failed What am I doing, rather NOT doing? Update So I downloaded nant, setup the .bat file in my PATH so it works in cmd prompt. I ran: nant default.buil...

Should Castle DynamicProxy IInterceptor or ProxyGenerator be cached?

I'm using StructureMap to Enrich some of my objects with an instance call to ProxyGenerator.CreateInterfaceProxyWithTarget(myObject, MYInterceptor) Currently I have the MYInterceptor inside my container, should I implement any type of caching for the interceptor? The second question should I register my ProxyGenerator inside my contai...

Wrapping existing objects to intercept method/property calls in .NET

I have a situation where I would like to intercept calls to properties in .NET. I have been looking at DynamicProxy in Castle and it seems to work fine. But it seems in order to use it I have to start with a new object, meaning I can't do something like this: MyType myType = new MyType(); myType.Property = "Test"; ... MyType wrappedM...

DynamicProxy2 and Proxy Chaining

I have the need to proxy the property types of a proxy. So the case would be: I have interface IMyInterface: public interface IMyInterface { public String Name {get; set;} public Int Id {get;set;} } I can mock the interface just fine but I want to be able to mock, for instance, the Name property. I realize that String cannot ...

Windsor Method interception (AOP)

Hi there guys, I'm trying to create interceptors for specific methods but I'm having a hard time. I can't bind an aspect to a specific method. I create the faicilities most of examples show but it still doesn't work. Can anyone give me an example of how to do this? I prefer xml conifguration, if possible. Another question, I have this ...

invoking 2 targets with Castle.DynamicProxy

Say I have an interface IInterface. Say I have 2 implementations of the same IInterface (foo & bar). Is it possible to invoke the same method on both targets? ...

Intercept only interface methods with DynamicProxy

I got an interface like this public interface IService { void InterceptedMethod(); } A class that implements that interface and also has another method public class Service : IService { public virtual void InterceptedMethod() { Console.WriteLine("InterceptedMethod"); } public virtual void SomeMethod() ...

Create an InterfaceProxyWithoutTarget with a default constructor

Hi all, Using Castle.DynamicProxy, I "simply" would like to get an Interface-Proxy-Without-Target, but... With a default-constructor so I be able to reuse the proxy-type. UPDATE I mean doing something like... var proxy = generator.CreateInterfaceProxyWithoutTarget(typeof(TInterface) ...); var proxyType = proxy.GetType(); var newproxy...

Castle DynamicProxy v1 exception when proxy-ing methods with parameters?

I'm having problems proxying metods with parameters using Castle DynamicProxy v1.1.5.0. - I get the exception "Index was outside the bounds of the array." If I only use methods with no parameters, OR DynamicProxy v2, everything works ok. Unfortunately, I'm having trouble convincing the leads on my project to add a dependency to v2 (we'...

Why am I getting "Invalid Internal state" reflection exception with Castle DynamicProxy?

We added DynamicProxy to our ASP.NET web app a couple of weeks ago. The code ran fine in dev and QA, but when we pushed to production, we got the following exception (top of stack trace only): [ArgumentNullException: Invalid internal state.] System.Reflection.Emit.TypeBuilder._InternalSetMethodIL(Int32 methodHandle, Boolean isInitLoca...

Caste Dynamic Proxy in Windsor Container

Hi, I've got a bit of a problem. I'm working in the Caste 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 at Interceptors and at the moment i am using the IInterceptor interface implemented ...

Access custom attribute on method from Castle Windsor interceptor

I am trying to access a custom attribute applied to a method within a castle interceptor, e.g.: [MyCustomAttribute(SomeParam = "attributeValue")] public virtual MyEntity Entity { get; set; } using the following code: internal class MyInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { if (invo...

How to intercept, parse and compile?

This is a problem I've been struggling to solve for a while. I need a way to either replace code in the method with a parsed code from the template at compile time (PostSharp comes to mind) or to create a dynamic proxy (Linfu or Castle). So given a source code like this [Template] private string GetSomething() { var template = [%=Cus...

[Castle-DynamicProxy] 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 with creating interceptors but i can't get the idea why interceptors are used with classes.....

Help Migrating mixins from Castle.DynamicProxy to DynamicProxy2

I am trying to update some code from using DynamicProxy to DynamicProxy2. In particular we where using DynamicProxy to provide a mixin of two classes. The setup is something like this: public interface IHasShape { string Shape { get; } } public interface IHasColor { string Color { get; } } public interface IColoredShape : IHas...

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 have everything working perfectly apart from the selective part. I could be wrong, but I ...

Castle Dynamic Proxy is it possible to intercept value types?

Hi, I have a problem and can not find answer and any tip if it is possible to intercept value types in C# by Castle dynamic proxy? I want to intercept IDictionary with INotifyChanged interface. I need this to update view when presenter is changing model. Boxing decimal in object only for making interface is not good idea... maybe somebod...

NHibernate + Remoting = ReflectionPermission Exception

Hi all, We are dealing with a problem when using NHibernate with Remoting in a machine with full trust enviroment (actually that's our dev machine). The problem happens when whe try to send as a parameter an object previously retrieved from the server, that contains a NHibernate Proxy in one of the properties (a lazy one). As we are i...

Is it possible to generate dynamic proxy for static class or static method in C#?

I am trying to come up with a way that (either static or instance) method calls can be intercepted by dynamic proxy. I want to implement it as c# extension methods but stuck on how to generate dynamic proxy for static methods. Some usages: Repository.GetAll<T>().CacheForMinutes(10); Repository.GetAll<T>().LogWhenErrorOccurs(); //or ...