fahadash
fahadash

Reputation: 3281

Can we find out from which assembly a method call came from?

I have a method in my .NET Class which has to implement security based on Caller-ID. I am curious if there is some way to tell where the call to my method came from ?

Upvotes: 0

Views: 144

Answers (2)

BradleyDotNET
BradleyDotNET

Reputation: 61339

Not easily. Using the diagnostics library you could potentially get there, but it wouldn't be pretty, easy, or extensible.

You can restrict method access with:

  • private: Only class members can access it
  • protected: Only class members and members of derived classes can access it
  • internal: Only members of classes within the same assembly can access it

If you can't trust your own code, you have bigger problems.

Upvotes: 0

fahadash
fahadash

Reputation: 3281

I found GetCallingAssembly method.

Upvotes: 1

Related Questions