Razer
Razer

Reputation: 8211

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
   ...

Upvotes: 1

Views: 1478

Answers (3)

Lee
Lee

Reputation: 144136

To get the location the assembly was found, use CodeBase instead of Location i.e.

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.

Upvotes: 2

JohnD
JohnD

Reputation: 14757

Can you use methodInfo.DeclaringType.Assembly.Location?

Upvotes: 0

spender
spender

Reputation: 120470

How about

methodInfo.DeclaringType.Assembly.Location

?

Upvotes: 5

Related Questions