views:

41

answers:

2

Hi,

I've made a .net 2.0 librabry project, that results in a dll. I've made an app.config file in my project, with settings used in the dll, with the intention that they can be changed later.

I'm attempting to use the dll in an asp.net web application now, so I made the reference to my other project's output, and I see that the dll is copied over to the site's bin folder, and everything works. However, the configuration file is not copied. When I manually copy the app.config and rename it to myDll.config, it has no influence.

The contents of the config file is approximately this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="myDLL.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <myDLL.My.MySettings>
               <setting name="myDLL_webservice_Service" serializeAs="String">
                      <value>https://myhost/Service.asmx&lt;/value&gt;
               </setting>
               <setting name="ID" serializeAs="String">
                      <value>6</value>
               </setting>
        </myDLL.My.MySettings>
    </applicationSettings>
</configuration>

And I use its settings in the dll with this (vb.net code):

    Private _id As Long = My.Settings.ID

How can I put my config information somewhere so it can be used?

  • In the web.config of the site application? That has only the appSettings section, and it uses the syntax. It doesn't appear to work though.

  • In a custom file format that I create and use? Not that pretty..

+1  A: 

You just can have one configuration file per application domain. You need to merge them, or to load it manually as explained here.

Rubens Farias
Interesting series that page links too, albeit a bit of a long text :) I'll read it after deadline, thanks!
Tominator
+1  A: 

Put both your configSections and your applicationSettings (these are not the same as appSettings) in your web.config file.

Matthew Abbott
Heh thanks, that works :D I must make sure that configSections is the first child of the configuration tag, otherwise .net complains that configSections has already been defined, but that's okay.
Tominator
Yeah, configSections is a special case in the config files, .NET uses it to validate what sections can be used in the current configuration file.
Matthew Abbott