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
>
>