简体   繁体   中英

Get assembly path from MethodInfo

I have a MethodInfo from a method out of a class library. Is it possible to determine the path where the assembly is located with just that info?

void foo(MethodInfo methodInfo)
{ 
    // Get the path of the DLL here
   ...

How about

methodInfo.DeclaringType.Assembly.Location

?

To get the location the assembly was found, use CodeBase instead of Location ie

methodInfo.DeclaringType.Assembly.Codebase

see here for a description of the difference. If your assembly is being shadow copied, you may find CodeBase more useful.

您可以使用methodInfo.DeclaringType.Assembly.Location吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM