473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to get the path of an installed DLL of VS .NET Add-in

Tee
Hi,

I am creating a VS .NET Add-in. There's an xml config file that will
installed to same folder as the DLL is installed.
The installation path probably is something like C:\Program Files\Company
Name\VSAddin

From the VS .NET Add-in, it needs to locate the xml config file and
read/write data to it.
Anyone know how can I get the folder location by coding?
I tried Application.StartupPath and also
AppDomain.CurrentDomain.BaseDirectory, but none of them just work.
What I get is something like C:\Program Files\Visual Studio 2003\Common\IDE
....

Can anyone help?

Thanks.
Regards,
Tee
Nov 16 '05 #1
6 1442
Hi Tee!

"Tee" schrieb
I am creating a VS .NET Add-in. There's an xml config file that will
installed to same folder as the DLL is installed.
The installation path probably is something like C:\Program Files\Company
Name\VSAddin

From the VS .NET Add-in, it needs to locate the xml config file and
read/write data to it.
Anyone know how can I get the folder location by coding?
I tried Application.StartupPath and also
AppDomain.CurrentDomain.BaseDirectory, but none of them just work.
What I get is something like C:\Program Files\Visual Studio
2003\Common\IDE


If you have a reference to your assembly you can use Assembly.Location.
However I don't think it is a good idea to store the config-file in the
application-folder because that would require write-permissions on that
folder. Users normally don't have write-permissions on the
application-folder. Better use the ApplicationData-folder for a specific
user.

Cheers

Arne Janning
Nov 16 '05 #2
Tee
Hi Arne,

Thanks for your reply.
Can you provide me with a little bit more of information?

What do you mean by I have reference to the assembly ?
My previous question was how the add-in detect it's own DLL location ...
and the Assembly.Location is under what namespace?

Thanks.
Tee
"Arne Janning" <sp*****************@msn.com> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi Tee!

"Tee" schrieb
I am creating a VS .NET Add-in. There's an xml config file that will
installed to same folder as the DLL is installed.
The installation path probably is something like C:\Program Files\Company Name\VSAddin

From the VS .NET Add-in, it needs to locate the xml config file and
read/write data to it.
Anyone know how can I get the folder location by coding?
I tried Application.StartupPath and also
AppDomain.CurrentDomain.BaseDirectory, but none of them just work.
What I get is something like C:\Program Files\Visual Studio
2003\Common\IDE


If you have a reference to your assembly you can use Assembly.Location.
However I don't think it is a good idea to store the config-file in the
application-folder because that would require write-permissions on that
folder. Users normally don't have write-permissions on the
application-folder. Better use the ApplicationData-folder for a specific
user.

Cheers

Arne Janning

Nov 16 '05 #3
Hi Tee!

"Tee" schrieb
Thanks for your reply.
Can you provide me with a little bit more of information?

What do you mean by I have reference to the assembly ?
My previous question was how the add-in detect it's own DLL location ...
and the Assembly.Location is under what namespace?


Import the System.Reflection-namespace.

Let's say you have defined a class in your assembly: MyAddinClass

You can get a reference to the assembly (the DLL) in which this class is
defined:

Assembly a = Assembly.GetAssembly(typeof(MyAddinClass));

Now a.Location contains the full-path to your DLL:

Debug.WriteLine(a.Location);

Cheers

Arne Janning
Nov 16 '05 #4
Tee
Arne,

Thanks for the code, it works.
But while waiting you or someone else to reply, I found that
Assembly.GetExecutingAssembly().Location work the same.

Between this 2 methods, what's the differences ?

and which to go with? any idea?

Thanks.

Tee

"Arne Janning" <sp*****************@msn.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Hi Tee!

"Tee" schrieb
Thanks for your reply.
Can you provide me with a little bit more of information?

What do you mean by I have reference to the assembly ?
My previous question was how the add-in detect it's own DLL location ...
and the Assembly.Location is under what namespace?


Import the System.Reflection-namespace.

Let's say you have defined a class in your assembly: MyAddinClass

You can get a reference to the assembly (the DLL) in which this class is
defined:

Assembly a = Assembly.GetAssembly(typeof(MyAddinClass));

Now a.Location contains the full-path to your DLL:

Debug.WriteLine(a.Location);

Cheers

Arne Janning

Nov 16 '05 #5
Hi Tee!

"Tee" schrieb
Thanks for the code, it works.
But while waiting you or someone else to reply, I found that
Assembly.GetExecutingAssembly().Location work the same.

Between this 2 methods, what's the differences ?

and which to go with? any idea?


If you for example develop a Windows.Forms-application and have one EXE
(GUI) and one DLL (Business Objects) then using
Assembly.GetExecutingAssembly().Location in your DLL will contain the path
for the EXE-file. I wasn't sure if the
Assembly.GetExecutingAssembly().Location of an add-in-dll would point to the
hosting application or not, this is why I didn't make this proposition. But
if it works as well, even better.

In contrast Assembly.GetAssembly(Type t) can get the assembly for every
known .NET-Type at runtime. E.g. Assembly.GetAssembly(typeof(int)).Location
will give you the path for the mscorlib.dll.

Cheers

Arne Janning
Nov 16 '05 #6
Tee
Arne,

Thanks a lot for all your help.
You rock! Cheers! :)
Thanks,
Tee
"Arne Janning" <sp*****************@msn.com> wrote in message
news:uT**************@TK2MSFTNGP14.phx.gbl...
Hi Tee!

"Tee" schrieb
Thanks for the code, it works.
But while waiting you or someone else to reply, I found that
Assembly.GetExecutingAssembly().Location work the same.

Between this 2 methods, what's the differences ?

and which to go with? any idea?
If you for example develop a Windows.Forms-application and have one EXE
(GUI) and one DLL (Business Objects) then using
Assembly.GetExecutingAssembly().Location in your DLL will contain the path
for the EXE-file. I wasn't sure if the
Assembly.GetExecutingAssembly().Location of an add-in-dll would point to

the hosting application or not, this is why I didn't make this proposition. But if it works as well, even better.

In contrast Assembly.GetAssembly(Type t) can get the assembly for every
known .NET-Type at runtime. E.g. Assembly.GetAssembly(typeof(int)).Location will give you the path for the mscorlib.dll.

Cheers

Arne Janning

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: hokiegal99 | last post by:
I installed Python-2.3 into c:\Program Files\Python23 on a new W2K SP4 computer. When I write a Python script and run it from the command prompt, I get the following error: C:\>python...
10
by: wen | last post by:
on my system(win2k server, python 2.3.5), >>> import sys >>> print sys.path now, i wanna add "C:\Python23\Pmw\Pmw_1_2\lib" into sys.path, how? any help would be appreciated. with my...
0
by: Shi Mu | last post by:
I have installed Python 2.3 and I type "help()" and then "Keywords". I get a list of words. And it says that I can enter any of the words to get more help. I enter "and" and I get the following...
1
by: Rob T | last post by:
I want to write a file into the directory my application is installed into. If I just write the file without a path, it will go to the user's working directory (ie, where he opened a file from)....
6
by: Amjad | last post by:
Can anyone tell me how to read the path value of an already installed and registered application called "Palm Desktop" from the Windows Registry? I just want my VB program to determine where...
1
by: Will Arrowsmith | last post by:
Hi all, I am trying to create a small form much like the Windows Explorer 'open with...' dialog box, which will contain a list of all applications installed on the local machine and their...
34
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH...
2
by: frikk | last post by:
This should be a very simple one, sorry! I installed wxWindows on my OS X box but I am unable to get my python install to recognize the module. Unfortunately I don't know a whole lot about...
5
jimpy
by: jimpy | last post by:
Greetings, When I open a terminal and enter :"echo $PATH", I receive this printout: I successfully add : But when I close the terminal, and later reopen and check the path, the...
2
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, For my desktop application, i want to add explorer like dektop function. But problem is that how can i detect the path of the programe. My programe imports all data from Windows explorer now...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.