473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class library and config files...again

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
2 1622
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2870
by: Florida Coder | last post by:
I have the need to store some application specific configuration data to be used by a class library and or a windows service. I would like to do this in a fashion similar to the way we do with...
5
555
by: AAguiar | last post by:
I have an asp.net project where the code behind the aspx page calls a c# class which makes calls to a managed static C++ class. The C# class works fine when the asp net worker process starts, when...
3
3934
by: ad | last post by:
I have a web application and a class library in a solution. The class library is make of typed datasets, and include many Table in it. The connection strings of the TableAdapters is come from...
3
18519
by: Fernando Chilvarguer | last post by:
Hello! I created a Class Library project in VS2005. Then, using VS, I was able to add a connection string to the project settings, which automaticaly created an app.config file for me. If I try...
0
2490
by: metaperl | last post by:
A Comparison of Python Class Objects and Init Files for Program Configuration ============================================================================= Terrence Brannon bauhaus@metaperl.com...
8
2412
by: Mihai Velicu | last post by:
Hi ! I created a class library and in it I have a class that call "ConfigurationManager" to find out what type of database I work and the connection string.When I call this class from a form,...
2
1706
by: Steve | last post by:
I want to call my web service from a class library and have that library handle all the wse stuff, so that applications using that library don't have to worry about it. Is that possible? I've...
3
3646
by: Andrew | last post by:
I have a class library that has app.config that has <system.diagnostics> that specifies trace listeners. The class library is loaded by a third party unmanaged application. I want the .NET...
7
10309
by: Peter Bradley | last post by:
OK. A bit behind the times, I know; but we're just moving over to .NET 2.0. How on earth do you manage configuration settings in a class library in .NET 2.0? In version 1.1, we used a handy class...
0
7063
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
7313
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...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.