开发者

DLL configuration file in asp.net site

I've made a .net 2.0 library 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" ?>开发者_C百科;
<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..


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜