在asp.net网站DLL的配置文件 [英] DLL configuration file in asp.net site

查看:184
本文介绍了在asp.net网站DLL的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个.NET 2.0库项目,这导致了一个dll。我已经在我的项目做一个app.config文件,在该dll使用的设置,以使他们能够在以后更改的意向。

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.

我试图使用一个asp.net web应用程序的DLL了,所以我做了参考我的其他项目的输出,而我看到的dll被复制到网站的bin文件夹,一切正常。然而,在配置文件不被复制。当我手动复制的app.config,并将其重命名为myDll.config,它有没有影响。

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>

和我在这个DLL使用其设置(vb.net code):

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?

  • 在网站应用程序的web.config? 具有只appSettings部分,它使用的语法。它似乎没有工作,虽然。

  • 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.

在我创建并使用自定义的文件格式? 这并不是说pretty的..

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

推荐答案

把双方的configSections和你的applicationSettings(这些都是不一样的appSettings)在你的web.config文件。

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

这篇关于在asp.net网站DLL的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆