How do I get the path of the assembly the code is in?

前端 未结 30 2753
小蘑菇
小蘑菇 2020-11-21 16:17

Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code.

<
30条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 16:48

    All of the proposed answers work when the developer can change the code to include the required snippet, but if you wanted to do this without changing any code you could use Process Explorer.

    It will list all executing dlls on the system, you may need to determine the process id of your running application, but that is usually not too difficult.

    I've written a full description of how do this for a dll inside II - http://nodogmablog.bryanhogan.net/2016/09/locating-and-checking-an-executing-dll-on-a-running-web-server/

提交回复
热议问题