access an actual object of ContextboundObject in sink class?

P

pinetaj

Hello,
I'd like to intercept some method invocations on certain object.
For the object, I wrote a class inherited from ContextBoundObject.
and also related classes to implement attribute, property, sink classes
required to intercept the method invocations.

The property created for the context implements IContributeObjectSink
(for GetObjectSink) so the each object's activity can be intercepted.
I want to access the actual object when sink class's methods get
executed during interception.
But, I found the sink returns MarshalByRefObject's TransparentProxy
instead of the actual object represented by the transparentProxy.

Is there any way to let the sink class's method access the actual
object which is the target of the interception?

Any advice will be helpful.
Thank you so much.
 
N

Nicholas Paldino [.NET/C# MVP]

pinetaj,

All you have to do is cast the object to the type you expect and then
you will be able to call the methods on it. The MarshalByRefObject is
passed because it is the subtype that all ContextBoundObjects have to derive
from.

Hope his helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top