Get actual dll path in .Net

.net, c#, dll, wpf

Solution

You can use:

Assembly.GetExecutingAssembly().Location

which will give you the path of the executing assembly then use:

System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

which will give the containing folder.

Problem

I have a dll named JIMS.Printing.dll which is placed inside the Reporting folder of the main application JIMS.exe. But I am getting an error when calling some files inside the Templates folder inside JIMS.Printing.dll code inside of Reporting which running JIMS.exe ``` JIMS.exe --------->Reporting ------------------->JIMS.Printing.dll ------------------->Templates -----------------------------> Files ``` Code: ``` string _templatePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(JIMS.Printing.PrintInvoice)).Location), "Templates"); ``` Code from JIMS.Printing.dll JIMS.exe looking for Files inside JIMS.exe Path\Templates\file, But actually the file is in JIMS.Printing.dll Path\Templates\files

Original source

Related problems