PC Review


Reply
Thread Tools Rate Thread

Class library and config files...again

 
 
OO
Guest
Posts: n/a
 
      3rd Apr 2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      3rd Apr 2006
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
>
>

 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      3rd Apr 2006
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.SpecialFolder.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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Config xaml for a WPF class library? Norbert Pürringer Microsoft C# .NET 0 10th Apr 2008 10:43 AM
app.config for class library? Microsoft Dot NET Framework 2 15th Oct 2005 05:13 PM
XML config files for Class library No One Microsoft ASP .NET 2 6th Oct 2004 12:09 PM
Class Library Reading from .config files Makarand Microsoft Dot NET Framework 1 29th Dec 2003 11:12 AM
config file for Class Library? Hayato Iriumi Microsoft C# .NET 3 17th Nov 2003 07:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:18 AM.