Path of dll

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)
 
M

Mattias Sjögren

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top