使用web.config中的商店中引用类库的Properties.Settings类? [英] Using web.config as store for referenced class library's Properties.Settings class?

查看:248
本文介绍了使用web.config中的商店中引用类库的Properties.Settings类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,

这可能是很简单,但我不能点上明确启用任何东西。

This is probably very simple, but I couldn't turn up anything explicitly on point.

我有一个Web应用程序(ASP.Net 4.0)引用类库。该类库有各种设置。我想使用的类库中的强类型Properties.Settings能力。然而,由于类库配置文件是ASP.Net下忽略了,我想的后备存储的设置是web.config中的一个部分,而不是一类特定库的app.config。

I have a web app (ASP.Net 4.0) that references a class library. The class library has various settings. I'd like to use the strongly-typed Properties.Settings capability within the class library. However, since class library config files are ignored under ASP.Net, I'd like the backing store for the settings to be a section of web.config as opposed to a class library-specific app.config.

我想,这是不是决绝禁止或者是易如反掌的事情。谁能告诉我如何使它工作?

I figure this is either outrightly forbidden or is as easy as pie to do. Can anyone tell me how to make it work?

谢谢,

安L.

推荐答案

我不是100%肯定你问什么,但我看到了两个可能的问题:

I'm not 100% sure what you're asking, but I see two possible questions:


  1. 该类库有由配置文件控制(套)的属性,但类库不消耗配置文件。如果是这样的话,那么所有你需要做的就是将这些设置,调用应用程序的配置文件 - 类库将自动使用调用应用程序的Web.config(或App.config中酌情)

  1. The class library has properties that are controlled (set) by the config file, but class libraries don't consume config files. If that's the case, then all you need to do is move those settings to the calling app's config file - the class library will automatically use the calling app's Web.config (or App.config, as appropriate).

您想创建一个自定义配置部分,它也可以做:的如何创建自定义配置节使用的ConfigurationSection

You want to create a custom Configuration Section, which can also be done: How to: Create Custom Configuration Sections Using ConfigurationSection

除非我完全误解你的问题(永远是与我:)可能性),我会用#1去,因为它更容易,除非有一些独特的,或在您的设计是要叫你们选项2必需的。

Unless I've totally misread your question (always a possibility with me :) ), I'd go with #1 as it's easier, unless there's something unique or required in your design to move you to option 2.

这篇关于使用web.config中的商店中引用类库的Properties.Settings类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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