Home All Groups Group Topic Archive Search About

Overriding non-virtual methods using IL and Reflection.Emit

Author
7 Jul 2006 5:48 PM
rfuller987
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

Author
7 Jul 2006 6:19 PM
Greg Young
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
>
Author
7 Jul 2006 8:19 PM
rfuller987
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
> >
Author
7 Jul 2006 8:49 PM
Greg Young
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
>> >
>
Author
10 Jul 2006 1:19 PM
rfuller987
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
> >> >
> >

AddThis Social Bookmark Button