web.config什么时候太大?

发布于 2024-09-11 13:41:35 字数 330 浏览 0 评论 0原文

当您向 Web 项目添加组件时,这些配置文件肯定会膨胀。 NHibernate、Castle、log4net——他们都想从这个行动中分得一杯羹。

本能地我更喜欢硬编码配置(当然假设配置数据不会改变太多)——像 Fluent NHibernate。我有点担心,如果配置文件变大,访问数据的速度会减慢,从而损害应用程序。我还倾向于认为编译代码中的数据比外部文件中的数据访问速度更快。

我的这个想法是对的吗?

另外,它是如何工作的?配置文件是否在第一次访问时被解析并加载到内存中?任何后续访问是否与其他类型的内存访问(例如访问局部变量)一样快?

感谢您提供任何信息。

大卫

Those configuration files sure can bloat as you add components to your web project. NHibernate, Castle, log4net - they all want a slice of that action.

Instinctively I tend to prefer hardcoded configuration (assuming of course the config data won't change much) - a la Fluent NHibernate. I kind of fear that if the config file becomes large, accessing data off it will slow down, to the application's detriment. I also tend to think that data in compiled code will be faster to access than data in an external file.

I am right in thinking this?

Also, how does it work? Is the config file parsed and loaded into memory the first time it is accessed? Is any subsequent access as fast as other types of in-memory access, like (say) accessing a local variable?

Thanks for any info.

David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静水深流 2024-09-18 13:41:35

如果您使用的是 Web 应用程序,则 ASP.NET 会监视配置文件,并在配置文件发生更改时重新加载它,但桌面应用程序通常不会。但是您可以轻松地将文件观察器添加到文件中来完成此操作。

但是,如果您的文件变得太大,需要考虑的一件事是将文件拆分为多个文件。 Scott Allen 有一篇关于此的好文章: http://odetocode.com/Articles/418.aspx< /a>

If you are in a web application then asp.net does monitor the config file and reload it if it changes but desktop apps typically do not. But you can easily add a file watcher to the file to accomplish this.

But if your files are getting too big one thing to consider is splitting the file into multiple files. Scott Allen has a good article here about this: http://odetocode.com/Articles/418.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文