473,785 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dll not reading .config ?

Hi

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

However when I use this class library, it doesn't seem to read the settings
myClasses.dll.c onfig file, instead I just get then initial values I used
when creating the settings.settin gs 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 3039

"Søren M. Olesen" <sm******@hotma il.com> wrote in message
news:e0******** ******@TK2MSFTN GP11.phx.gbl...
However when I use this class library, it doesn't seem to read the
settings myClasses.dll.c onfig file, instead I just get then initial values
I used when creating the settings.settin gs 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.Collecti ons.Specialized
Imports System.Reflecti on.Assembly

Public Class AssemblyConfigu rationSettings
Public Shared ReadOnly Property AppSettings() As NameValueCollec tion
Get
Dim filename As String = GetCallingAssem bly.Location & ".config"
Dim settings As New NameValueCollec tion
If Not System.IO.File. Exists(filename ) Then
Return settings
End If

Try
Dim reader As New System.Xml.XmlT extReader(filen ame)
Dim doc As New System.Xml.XmlD ocument
doc.Load(reader )

Dim configurationNo de As System.Xml.XmlN ode =
doc.SelectSingl eNode("configur ation")
If configurationNo de Is Nothing Then
Return settings
End If

Dim appSettingsNode As System.Xml.XmlN ode =
configurationNo de.SelectSingle Node("appSettin gs")
If appSettingsNode Is Nothing Then
Return settings
End If

Dim nodes As System.Xml.XmlN odeList =
appSettingsNode .SelectNodes("a dd")
For Each node As System.Xml.XmlN ode In nodes
settings.Add(no de.Attributes(" key").Value,
node.Attributes ("value").Value )
Next
Catch ex As System.Xml.XmlE xception
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******@hotma il.com> wrote in message
news:e0******** ******@TK2MSFTN GP11.phx.gbl...
However when I use this class library, it doesn't seem to read the
settings myClasses.dll.c onfig file, instead I just get then initial
values I used when creating the settings.settin gs 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
2061
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
2429
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, it does not return the values from my web.config. The web.config is located in the root of the web application. The classic asp page that calls the COM exposed c# assembly is located in a subfolder called message. Can anyone help me out here?
2
5106
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 any application that uses the data access application building block from Microsoft's Enterprise Library (patterns and practices site). I want to allow the users to select the database connection. To do this, I thought I could read the...
1
1697
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
9471
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 ConfigurationErrorException whenever I do the following: 1. Modify and save the section in code using the System.Configuration.Configuration.Save(). 2. Refresh teh section using ConfigurationManager.RefreshSection 3. Encrypt the section,...
2
1556
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 to read config from x:\inetpub\wwwroot\web.config. Correct path is x:\inetpub\wwwroot\test\web.config. How to force on application (or IIS or whatever) to use correct config?
5
10339
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 get the following error on the page: Security Exception Description: The application attempted to perform an operation not allowed
9
2721
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): System.Collections.Specialized.NameValueCollection SectionIndex = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationSettings.GetConfig("Rewrite.NET/Index"); The value always returns me null, and just to check it was...
1
7492
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 contains settings related to business logic coded in that component. I can reference and load the component but unable to read load the custom config file of that component. I know that the same thing is possible if my host application is any Exe...
1
2268
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3654
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.