|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Overriding non-virtual methods using IL and Reflection.EmitIs it possible to override non-virtual methods using Reflection.Emit.
I'm creating dynamic proxy classes at runtime and I want to be able to proxy all public methods on an object, regardless of whether the object author happened to mark them as virtual or not. Is this possible? -rfuller987 rfuller***@hotmail.com No.(Notice that every dynamic proxy has this limitation).
Cheers, Greg Young MVP - C# http://codebetter.com/blogs/gregyoung <rfuller***@hotmail.com> wrote in message Show quote news:1152294512.545451.26400@b28g2000cwb.googlegroups.com... > Is it possible to override non-virtual methods using Reflection.Emit. > I'm creating dynamic proxy classes at runtime and I want to be able to > proxy all public methods on an object, regardless of whether the object > author happened to mark them as virtual or not. Is this possible? > > -rfuller987 > rfuller***@hotmail.com > That's a real problem. That makes real aspect oriented programming in
..net impossible. Greg Young wrote: Show quote > No.(Notice that every dynamic proxy has this limitation). > > Cheers, > > Greg Young > MVP - C# > http://codebetter.com/blogs/gregyoung > > <rfuller***@hotmail.com> wrote in message > news:1152294512.545451.26400@b28g2000cwb.googlegroups.com... > > Is it possible to override non-virtual methods using Reflection.Emit. > > I'm creating dynamic proxy classes at runtime and I want to be able to > > proxy all public methods on an object, regardless of whether the object > > author happened to mark them as virtual or not. Is this possible? > > > > -rfuller987 > > rfuller***@hotmail.com > > Well I think you picked the right person to talk to. I have some experience
in the area :) There are other ways of implementing AOP than the dynamic proxy ... There are also numerous AOP frameworks with this virtual limitation .. see CastleProject, nAspect, spring .net People have also looked at such operations as using the profiling API to instrument IL just before JIT (this is being frowned on a bit).Personally I at this point am leaning towards a "link" time IL based weave ... If you happen to be in the southern US I will be speaking on this subject in New Orleans the 17th. Cheers, Greg Young MVP - C# http://codebetter.com/blogs/gregyoung <rfuller***@hotmail.com> wrote in message Show quote news:1152303596.434762.13340@m79g2000cwm.googlegroups.com... > That's a real problem. That makes real aspect oriented programming in > .net impossible. > > Greg Young wrote: >> No.(Notice that every dynamic proxy has this limitation). >> >> Cheers, >> >> Greg Young >> MVP - C# >> http://codebetter.com/blogs/gregyoung >> >> <rfuller***@hotmail.com> wrote in message >> news:1152294512.545451.26400@b28g2000cwb.googlegroups.com... >> > Is it possible to override non-virtual methods using Reflection.Emit. >> > I'm creating dynamic proxy classes at runtime and I want to be able to >> > proxy all public methods on an object, regardless of whether the object >> > author happened to mark them as virtual or not. Is this possible? >> > >> > -rfuller987 >> > rfuller***@hotmail.com >> > > Do you have any more information on this 'link' time IL based weave.
Sounds promising, although I don't think I have the expertise to implement it myself. How does .net remoting work? Doesn't it manage to proxy any MarshalByRef object regardless of the object's functions being marked as virtual? -rfuller Greg Young wrote: Show quote > Well I think you picked the right person to talk to. I have some experience > in the area :) > > There are other ways of implementing AOP than the dynamic proxy ... > > There are also numerous AOP frameworks with this virtual limitation .. see > CastleProject, nAspect, spring .net > > People have also looked at such operations as using the profiling API to > instrument IL just before JIT (this is being frowned on a bit).Personally I > at this point am leaning towards a "link" time IL based weave ... > > If you happen to be in the southern US I will be speaking on this subject in > New Orleans the 17th. > > Cheers, > > Greg Young > MVP - C# > http://codebetter.com/blogs/gregyoung > > <rfuller***@hotmail.com> wrote in message > news:1152303596.434762.13340@m79g2000cwm.googlegroups.com... > > That's a real problem. That makes real aspect oriented programming in > > .net impossible. > > > > Greg Young wrote: > >> No.(Notice that every dynamic proxy has this limitation). > >> > >> Cheers, > >> > >> Greg Young > >> MVP - C# > >> http://codebetter.com/blogs/gregyoung > >> > >> <rfuller***@hotmail.com> wrote in message > >> news:1152294512.545451.26400@b28g2000cwb.googlegroups.com... > >> > Is it possible to override non-virtual methods using Reflection.Emit. > >> > I'm creating dynamic proxy classes at runtime and I want to be able to > >> > proxy all public methods on an object, regardless of whether the object > >> > author happened to mark them as virtual or not. Is this possible? > >> > > >> > -rfuller987 > >> > rfuller***@hotmail.com > >> > > > |
|||||||||||||||||||||||