views:

4931

answers:

2

Hi!

Is there some smart way to retreive the installation path when working within a dll (C#) which will be called from an application in a different folder?

I'm developing an add-in for an application. My add-in is written in C#. The application that will use is written in C and needs to compile some stuff during evaluation, so I have a middlestep with a C++ dll that handles the interop business with C# and only shows a clean interface outward that C can work with.

What I deploy will be a set of .dll's and a .lib and .h for the C++ part (sometimes static binding will be necessary).

When trying out the setup and printing out the current directory info from the C# dll with:

        Console.WriteLine(Directory.GetCurrentDirectory());

or:

        Console.WriteLine(System.Environment.CurrentDirectory);

I get the executables path.

So ... once again, how do I get the installation path of my dll?

Edit: They both worked! Thanks for the quick reply guys!

+6  A: 

I think what you want is Assembly.GetExecutingAssembly().Location.

tvanfosson
+1  A: 

Try this:

typeof(TypeInMyModule).Assembly.Location
Cristian Libardo