By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,978 Members | 1,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,978 IT Pros & Developers. It's quick & easy.

Class library and config files...again

P: n/a
OO
Hi all,

OK loads of posts on here about developers trying to use an app.config
for a dll class library. Of course I would normally say the config
file is down to the app domain of the application calling your class
library: a web app or an exe.

However....in my case, I need to call this class library from vbscript
for some legacy applications and so I do not have an Xml config file.
I am happy to create a class which I use to hold my config logic and
open an Xml file and use the XmlDocument for loading it up and working
through it.

But I really want to call this file <namespace>.dll.config and for it
to automally pull in the location of the dll: The files should be next
to each other in the same directory. However, if I do
xmlDoc.Load("<namespace>.dll.config") it automatically pulls in the
directory path to my test console app which I am using to test my class
library.

Basically I need to find a way of being able to call .Load() and pull
in the location of the current executing dll....not sure if this is
possible.

I am really trying to avoid hard coding the location of the Xml
file.....yuck

Cheers,

Olly

Apr 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If I understand your question correctly, you probably want to look at the
Assembly.GetExecutingAssembly() method in the System.Reflection namespace,
which returns you the current assembly from which this method is called. Then
you can access the Name and other properties of this to get what you want for
your config filename.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"OO" wrote:
Hi all,

OK loads of posts on here about developers trying to use an app.config
for a dll class library. Of course I would normally say the config
file is down to the app domain of the application calling your class
library: a web app or an exe.

However....in my case, I need to call this class library from vbscript
for some legacy applications and so I do not have an Xml config file.
I am happy to create a class which I use to hold my config logic and
open an Xml file and use the XmlDocument for loading it up and working
through it.

But I really want to call this file <namespace>.dll.config and for it
to automally pull in the location of the dll: The files should be next
to each other in the same directory. However, if I do
xmlDoc.Load("<namespace>.dll.config") it automatically pulls in the
directory path to my test console app which I am using to test my class
library.

Basically I need to find a way of being able to call .Load() and pull
in the location of the current executing dll....not sure if this is
possible.

I am really trying to avoid hard coding the location of the Xml
file.....yuck

Cheers,

Olly

Apr 3 '06 #2

P: n/a
Hi,

I have a similar situation here, I wrote a plugin for ArcGIS and of course
there is no exe involved, just a .dll . What I did was creating a file with
the same name than the dll and saved it in ApplicationData:

System.Environment.GetFolderPath(Environment.Speci alFolder.ApplicationData);

You can then use reflection to get the assembly name :

Assembly.GetExecutingAssembly().GetName().FullName
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"OO" <ol******@hotmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Hi all,

OK loads of posts on here about developers trying to use an app.config
for a dll class library. Of course I would normally say the config
file is down to the app domain of the application calling your class
library: a web app or an exe.

However....in my case, I need to call this class library from vbscript
for some legacy applications and so I do not have an Xml config file.
I am happy to create a class which I use to hold my config logic and
open an Xml file and use the XmlDocument for loading it up and working
through it.

But I really want to call this file <namespace>.dll.config and for it
to automally pull in the location of the dll: The files should be next
to each other in the same directory. However, if I do
xmlDoc.Load("<namespace>.dll.config") it automatically pulls in the
directory path to my test console app which I am using to test my class
library.

Basically I need to find a way of being able to call .Load() and pull
in the location of the current executing dll....not sure if this is
possible.

I am really trying to avoid hard coding the location of the Xml
file.....yuck

Cheers,

Olly

Apr 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.