Groups | Blog | Home
all groups > dotnet clr > april 2005 >

dotnet clr : MessageSink



Bart
4/25/2005 9:43:04 AM
Hi,

I'm designing a small AOP framework (for my thesis) and I'm planning to use
MessageSinks. There is just one problem: I want to identify (from within the
MessageSink) the client that is using the ContextBoundObject .

Any suggestions?

Thanks in advance,

KR

briangru NO[at]SPAM online.microsoft.com
4/30/2005 12:00:00 AM
I haven't used message sinks before. But if you have an instance of the
object you're interested in looking at, then you can try casting the object
to a ContextBoundObject. C# makes this easier with the "is" and "as"
keywords - would something like this work for you?

void Foo(Object obj) {
if (obj as ContextBoundObject) {
// ...
}
}

Reflection has an IsAssignableFrom method as well to assist in cases like
this.
Sherif
5/8/2005 12:00:00 AM
Hello

System.Diagnostics.StackTrace class would return the method that called your
method.
But there are 2 problems with this method
First you get only method info, not the object instance that for that
method.
Second in a release version a method could be inlined and won't appear in a
stack trace because of JIT optimizations.

I have researched this a bit before, but I didn't invest much time, so there
might be a better way.

Best regards,
Sherif

[quoted text, click to view]

AddThis Social Bookmark Button