mercredi 6 juillet 2016

How to get current physical path of a reflected assembly

I have an executable that loads another class library DLL using reflection. Within that class library, I want to find out what the physical path of the class library is. I don't want the executing assembly, as that is the original executable.

Eg the exe might be in c:\program\ and the class library might be c:\libraries\remote\Assembly1.dll

Within a method inside Assembly1.dll I need to call something that returns me

c:\libraries\remote\

I have tried

  var currentLocation = Assembly.GetAssembly(GetType()).Location;

But that doesn't seem to work. How can I do this?





Aucun commentaire:

Enregistrer un commentaire