Reputation: 50328
I'm writing a logging/debugging library, and it would be useful if the library could dynamically figure out and report on which projects/libraries are calling into it.
Can I identify who is calling a given function in my library (say, if I call Log("blah") from both a web application and a windows system service, can the Log function figure out where it was called from)?
Upvotes: 0
Views: 38
Reputation: 18965
System.Reflection.Assembly.GetCallingAssembly()
will tell you which assembly called your logging library.
Upvotes: 2