企业库类库App.Config中 [英] Enterprise Library Class Library App.Config

查看:154
本文介绍了企业库类库App.Config中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类库whcih是企业库的包装类记录应用程序块。在那里,我保持一个app.config配置文件。在所有的企业图书馆相关的配置present。

I have a class library whcih is a Wrapper class for Enterprise Library Logging Application Block. There I kept an App.Config configuration file. Where all the Enterprise Library related configurations are present.

现在我在一个ASP.NET Web应用程序所指向这个类库。问题我得到的是:ASP.NET Web应用程序是无法读取App.config文件获取配置信息。而我得到以下异常:

Now I refered this Class Library in a ASP.NET Web Application. Problem I am getting is: The ASP.NET Web Application is unable to read the App.Config file to fetch Configuration Information. And I am getting below Exception:

推荐答案

配置文件是每个AppDomain,而不是按二进制。如果你有一个.exe,它会寻找的.config,在一个Web应用程序,它看起来在web.config中。有一些技巧可以使用,但他们都将参与的的东西的主配置文件 - 你无法避免它在大多数情况下

Config files are per appdomain, not per binary. If you've got an .exe, it'll looking .config, in a web app, it looks in web.config. There are some tricks you can use, but they all involved putting something in the main config file - you can't avoid it for the most part.

做最简单的事情是把信息在web.config文件中。还有一些其他的选择,但他们得到越来越复杂。您正在使用什么版本的Entlib的?如果使用的是5.0,还有的编程配置支持(配置建设者的东西),使得在相当容易通过code设置entlib设置 - 你可以在你的库使用这些如果配置实际上是固定的。

The easiest thing to do would be to put the information in the web.config file. There are some other options, but they get increasingly more complicated. What version of Entlib are you using? If using 5.0, there's the programmatic configuration support (the configuration builder stuff) that makes is reasonably easy to set up entlib settings through code - you could use those in your library if the configuration is actually fixed.

虽然你提到​​你的包裹日志程序块,但屏幕截图显示了异常块。是你的主要的应用程序将使用Entlib为好,或者只是通过你的包装?

Although you mention you're wrapping the logging block, but the screenshot shows the exception block. Is your main app going to be using Entlib as well, or just through your wrappers?

这篇关于企业库类库App.Config中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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