C# 在 Visual Studio 中重建 app.config?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15399216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rebuilding app.config in visual studio?
提问by Solorzano Jose
My app.config was giving me several messages related to "usersettings schema not found", so I deleted it with the intention of building it from scratch, but I was not successful. How can I build a new one based on my settings file? Whenever I make a new one and build the solution, it doesn't build the app config file. I don't know what else to try.
我的 app.config 给了我几条与“找不到用户设置架构”相关的消息,所以我删除了它,打算从头开始构建它,但我没有成功。如何根据我的设置文件构建一个新的?每当我创建一个新的并构建解决方案时,它都不会构建应用程序配置文件。我不知道还能尝试什么。
Here's the troublesome part of my old file:
这是我的旧文件中麻烦的部分:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<userSettings>
<DelocksNote.Settings1>
<setting name="Font" serializeAs="String">
<value>DejaVu Sans, 20.25pt, style=Italic</value>
</setting>
<setting name="WordWrap" serializeAs="String">
<value>False</value>
</setting>
</DelocksNote.Settings1>
</userSettings>
回答by HeyThereLameMan
For anyone visiting in the future...
对于将来访问的任何人......
Delete the app.config file in your solution explorer. Right click the project and select add, add new item. Find "Application Configuration File" in the list and add it. It will be empty.
删除解决方案资源管理器中的 app.config 文件。右键单击项目并选择添加,添加新项目。在列表中找到“应用程序配置文件”并添加。它将是空的。
To generate the contents based on your settings (which should still be in tact): edit a setting (make a space or something) and save. Then go look at your new app.config file. It will be re-built!
要根据您的设置生成内容(应该仍然完好无损):编辑设置(创建一个空间或其他东西)并保存。然后去看看你的新 app.config 文件。它将被重建!