I need to retrieve the directory where the plugin DLL resides. When I use the usual C# code for this, Directory.GetCurrentDirectory(), I get the location of the RevIt installation on my machine, and not the directory where the running DLL is located. Is there a way, through the API, to retrieve the location of the running DLL?
Thanks in advance,
Scott S
Research Programmer
Center for Research Computing
University of Notre Dame
Solved! Go to Solution.
String executablePath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
should do the trick.
I am using macro and getting an error on assembly not found. Is there a solution for that?
The name 'Assembly' does not exist in the current context (CS0103) - C:\ProgramData\Autodesk\Revit\Macros\2015\Revit\AppHookup\CConvert\Source\CConvert\ThisApplication.cs:55,62
I am using application specific macro so I can use VS later. This is only short term testing right now. There are dll.
The solution accepted here does not work for 2017. It returns the location of the .addin file, not the location of the executing dll which is in a .bundle sub-folder. I have only just picked up that my support help files are not being found, although were previously. Has there been a change for 2017? I have also tried various suggestions with no success. In fact they return the same.
public static string GetDLLFolder() { string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(path); }
Thanks, Dale