Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 只能获取8项appsettings?_.net_F#_System.configuration - Fatal编程技术网

.net 只能获取8项appsettings?

.net 只能获取8项appsettings?,.net,f#,system.configuration,.net,F#,System.configuration,我正在使用System.Configuration.ConfigurationManager.AppSettings.[…”]。但是,我发现新添加的在执行时总是得到空值 System.Configuration.ConfigurationManager.AppSettings。[“new1”](app.config文件中的顺序无关紧要) Visual studio调试器显示System.Configuration.ConfigurationManager.AppSettings.AllKeys的

我正在使用
System.Configuration.ConfigurationManager.AppSettings.[…”]
。但是,我发现新添加的
在执行时总是得到空值
System.Configuration.ConfigurationManager.AppSettings。[“new1”]
app.config
文件中的顺序无关紧要)


Visual studio调试器显示
System.Configuration.ConfigurationManager.AppSettings.AllKeys
的类型为
string[8]
。为什么只有8件

听起来Visual Studio正在对bin\Release文件夹进行版本构建,而不是更新bin\Debug的内容

默认的VisualStudio项目包括两个“配置”——调试和发布。如果Visual Studio设置为执行调试生成,则默认情况下会写入bin\Debug文件夹。如果Visual Studio设置为执行版本生成,则会写入bin\Release文件夹。所有这些东西都可以为项目和解决方案定制

要在“配置”之间切换,请在工具栏中查找显示“释放”的下拉框。如果将其更改为“调试”并执行重建,您将发现bin\Debug文件夹中的xxx.exe.config已被更新的应用程序设置正确覆盖


顺便说一句,VisualStudio有一个“批量构建”功能,可以用来构建调试构建和发布构建。它位于Build菜单项下。

这不是一个类型,而是数组中有多少项。数组的类型是
string[]
。还要确保配置文件确实存在。它应该命名为“MyAppName.exe.config”,而不是“app.config”。如果没有,您将得到如前面所讨论的空值,我将在VisualStudio中运行它。我有10件东西。我发现
Bin\Debug\..exe.config
只有8项。为什么Visual studio不通过更新的app.config更新文件?更奇怪的是。我清理了项目并重建了它。但是,它创建了xxx.exe.config,修改日期为2014年7月21日。。。。现在没有appsettings会话。Visual Studio将在生成或调试项目时将项目的
app.config
复制到
Debug
文件夹中的
YourAppName.exe.config
。您的项目是否有
app.config
文件,或者您是否直接在
Debug
文件夹中修改了该文件?您是如何将
app.config
添加到项目中的?您在哪个文件中添加了
appsettings
部分?我有一个
app.config
并在那里添加了appsettings。我从不直接修改调试文件夹中的文件。我使用Visual studio添加该文件。我了解默认的两种配置-调试和发布。我确实切换了这两种配置进行测试。问题是为什么Visual studio不基于app.config创建新的xxx.exe.config文件,而是在调试配置中创建一个barebone xxx.exe.config。我建议关闭Visual studio。正在删除bin文件夹。正在重新启动Visual Studio。执行调试和发布构建。您观察到了什么?我清理了解决方案(删除了Bin\Debug和Bin\Release文件夹中的所有内容),并重建了Debug和Release。Bin\Debug\xxxx.exe.config是带有项目创建时间戳的基本文件,而Bin\Release\xxx.exe.config是用app.config更新的,它们具有相同的时间戳。我刚刚测试了它。清理解决方案只会删除当前选定配置的内容。我建议关闭VisualStudio。删除bin和obj文件夹。正在重新启动Visual Studio。执行调试和发布构建。你观察到了什么?