Path of dll

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have developed a com interop dll to be used in excel. In the dll I need to
read a file which exists in the same path as that of dll.How do I find the
path of the dll. When I use GetExecutingAssembly (as shown below) it gets the
path of Excel and not that of the dll. Any help is appreciated. Thanks.


********code************
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
 
I have developed a com interop dll to be used in excel. In the dll I need to
read a file which exists in the same path as that of dll.How do I find the
path of the dll. When I use GetExecutingAssembly (as shown below) it gets the
path of Excel and not that of the dll. Any help is appreciated. Thanks.

What do you get with

path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().Location)



Mattias
 
If your DLL is being used by the Excel process then Excel will be the
executing assembly when you run your dll code.

I would suggest that you enter a value (the path you where the DLL resides)
in the system registry (this can be done at install time) and then your dll
reads the value from the registry to find out where it is located on the
computer.

Hope that helps
Mark.
 
Back
Top