DLL configuration file in asp.net site

Posted by Tominator on Stack Overflow See other posts from Stack Overflow or by Tominator
Published on 2010-06-08T09:51:20Z Indexed on 2010/06/08 9:52 UTC
Read the original article Hit count: 203

Filed under:
|
|

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</value>
               </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..

© Stack Overflow or respective owner

Related posts about .NET

Related posts about dll