visual-studio-2008 - Visual Studio 2008 App.config 缓存

标签 visual-studio-2008 caching app-config

在过去的几个月里,我的 app.config 遇到了一些问题。 我将添加一个 AppSetting 键并运行我的项目,没有任何实际问题它读取配置文件并且一切都很好。然后在以后我将更改同一个键的值,当我运行我的项目时,我将获得该键的旧值。它似乎没有正确保存文件或检测到 app.config 文件发生了变化。如果我清理或重建我的解决方案就没问题。有没有其他人看到这个问题,有热修复吗?这是一个必须一直仔细检查的真正问题,尤其是当 key 通常是生产环境和测试环境之间的差异时。想象一下当我开始向我的生产环境发布测试消息时我的惊讶,可怕的。

提前致谢

最佳答案

编译时,您的 app.config 会被复制到 bin/Debug 或 bin/Release 文件夹。如果您更改源文件夹中的 app.config,但不重新编译,则更改不会传播。您需要重建以将其移动到代码实际执行的文件夹中。

或者,修改 bin/Debug/app.config 文件。

I dont think that that is the case that a re-build is necessary, every time i compile it should check that file and if changes then copy it up. But i cant imagine that everytime i make a change that i would have to do a rebuild for the compiler to recognize my changes. Rebuild vs build rebuild fixes my issue and recompiles all output whereas a build from my understanding checks for any changes to any files and releases only those files

您不必清理/重建,只需重新编译(F6 而不是构建 -> RebuildSolution)即可传播 app.config。但至少,您的代码必须重新编译。

我想知道...您是否可能将 app.config 文件的“复制到输出目录”属性设置为“不复制”?要检查:在解决方案资源管理器中右键单击 app.config,单击属性。

关于visual-studio-2008 - Visual Studio 2008 App.config 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/997832/

相关文章:

java - Tangosol Coherence 可以缓存不可序列化的对象吗?

Django - 'myapp' vs 'myapp.apps.myappConfig' in settings.py Installed Apps

c++ - vc90 上的 jsoncpp?

c# - Visual Form 继承不适用于 Visual Studio 2008 中的智能设备/紧凑型框架

基于 C 的控制台应用程序从 cmd.exe 运行时崩溃,在 VS2008 调试器中运行良好?

c++ - 增量挑战 :++ vs. +1

c++ - Visual Studio 2008 中缺少代码分析节点

java - 任何可以限制内存缓存的内存使用的 Java 缓存,而不仅仅是实例计数?

c# - 如何在程序的 app.config 文件中存储文件路径?

.net - 使用 SignedXml.ComputeSignature 将签名添加到配置文件后为 "Unrecognized configuration section"