C# - Get calling method's Assembly?

前端 未结 5 798
时光取名叫无心
时光取名叫无心 2020-12-16 09:27

Is there a way in C# to get the Assembly of the calling method? (Not the current method.)

i.e. I want the executing assembly, one a

5条回答
  •  萌比男神i
    2020-12-16 10:00

    No it's not possible to reliably understand who is calling you. Some people will undoubtedly suggest a stack walk but that is unreliable due to JIT inlining. There is just no way to reliably get the method / assembly which is calling your method.

提交回复
热议问题