Get actual dll path in .Net
Solution 1
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.
Solution 2
YOu can try this:-
string path1= System.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location;
string directory= Path.GetDirectoryName( path1 );
Kishore Kumar
OpenText Content Server Developer, Windows Developer, Web Designer & Developer. Interested in VB.Net,C#,WPF,ASP.Net,ASP.Net MVC,XAML,WCF,OScript, BackboneJS, Marionette http://www.dignaj.com/kishore/
Updated on June 26, 2022Comments
-
Kishore Kumar almost 2 years
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