C# Get path of class library

.net, assemblies, c#

Solution

I know this is an old post but in the event someone else stumbles on it from a search, the easiest way I've found to do this is:

Public Class Foo

     Public Shared Function GetMyPath() As String
          Return Path.GetDirectoryName(GetType(Foo).Assembly.Location)
     End Function

End Class

Problem

I have a class library that uses some xml files found in its own directory. When referencing this library from another project, how do I ensure the library is working from it's own directory? I tried Assembly.GetExecutingAssembly().Location but that still returns the path of the startup project.

Original source