473,395 Members | 1,856 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,395 software developers and data experts.

dll not reading .config ?

Hi

I've created a Class library (myClasses.dll), and added a settings.settings
to it using designer.

However when I use this class library, it doesn't seem to read the settings
myClasses.dll.config file, instead I just get then initial values I used
when creating the settings.settings section.

What do I have to do to get the classlibrary to read the associated .config
file???

TIA

Søren
Mar 31 '06 #1
3 3020

"Søren M. Olesen" <sm******@hotmail.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
However when I use this class library, it doesn't seem to read the
settings myClasses.dll.config file, instead I just get then initial values
I used when creating the settings.settings section.


I've only ever seen these values read from an Application.EXE.config
which, annoyingly, means you have to ship these settings in every
application that uses your library.

Or, in a web application, (I think) these settings are read from the
web.config file.

HTH,
Phill W.
Mar 31 '06 #2
Phill,

I don't really see that as a problem in most situations. When you add
a reference to the assembly you should also add the appropriate
settings to the app.config at that time. In other words, you add them
at compile and not deployment time. Furthermore, even if the
configuration infrastructure supported the *.dll.config method you'd
still have to deploy that file to every machine, but now you have more
than one file to keep track of.

Brian

Phill W. wrote:
I've only ever seen these values read from an Application.EXE.config
which, annoyingly, means you have to ship these settings in every
application that uses your library.

Or, in a web application, (I think) these settings are read from the
web.config file.

HTH,
Phill W.


Mar 31 '06 #3
I just recently needed this functionality so here's the class I made to
accomplish it:

Imports System.Collections.Specialized
Imports System.Reflection.Assembly

Public Class AssemblyConfigurationSettings
Public Shared ReadOnly Property AppSettings() As NameValueCollection
Get
Dim filename As String = GetCallingAssembly.Location & ".config"
Dim settings As New NameValueCollection
If Not System.IO.File.Exists(filename) Then
Return settings
End If

Try
Dim reader As New System.Xml.XmlTextReader(filename)
Dim doc As New System.Xml.XmlDocument
doc.Load(reader)

Dim configurationNode As System.Xml.XmlNode =
doc.SelectSingleNode("configuration")
If configurationNode Is Nothing Then
Return settings
End If

Dim appSettingsNode As System.Xml.XmlNode =
configurationNode.SelectSingleNode("appSettings")
If appSettingsNode Is Nothing Then
Return settings
End If

Dim nodes As System.Xml.XmlNodeList =
appSettingsNode.SelectNodes("add")
For Each node As System.Xml.XmlNode In nodes
settings.Add(node.Attributes("key").Value,
node.Attributes("value").Value)
Next
Catch ex As System.Xml.XmlException
End Try

Return settings
End Get
End Property
End Class

/claes

"Phill W." <p-***********@o-p-e-n.a-c.u-k> wrote in message
news:e0**********@yarrow.open.ac.uk...

"Søren M. Olesen" <sm******@hotmail.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
However when I use this class library, it doesn't seem to read the
settings myClasses.dll.config file, instead I just get then initial
values I used when creating the settings.settings section.


I've only ever seen these values read from an Application.EXE.config
which, annoyingly, means you have to ship these settings in every
application that uses your library.

Or, in a web application, (I think) these settings are read from the
web.config file.

HTH,
Phill W.

Mar 31 '06 #4

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

Similar topics

1
by: Sami | last post by:
Hello, I have this problem that I need your help with : I am reading a config file that contain the following : 2004 update
3
by: spacekid | last post by:
Hi there I am exposing a c# assembly as a COM component (regasm /codebase) and calling it from classic asp. When I try to call the ConfigurationSettings.AppSettings function in the c# assembly,...
2
by: news.microsoft.com | last post by:
Hi After conducting a several searches, I wasn't sure where to post this question. So my apologiesbefore hand for double posting this and possibly posting to the wrong forum(s). Okay, I have...
1
by: comic_rage | last post by:
Hi, I am trying to read from my application config file and keep getting null. Here is my config file My application is called SampleApp.exe
10
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
2
by: marek zegarek | last post by:
Hello! On my server I have Sharepoint portal server as default web site I create there a web application folder with form.aspx file. When I'm trying to run aspx, i get an error. Page is trying...
5
by: alf | last post by:
Hi folks, I'm trying to read a web.config section using RoleManagerSection settings = (RoleManagerSection)System.Configuration.ConfigurationManager.GetSection("system.web/roleManager"); and I...
9
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): ...
1
by: M Irfan | last post by:
Hello all, Recently I have started working in .NET 2.0. I am developing a web service application that references a DLL component written in C# 2.0. The component has its own config file which...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
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: 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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.