vb.net App.config 在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1267298/
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
Where is App.config?
提问by Zian Choy
I'm trying to set up logging with Microsoft's Enterprise Library (log4net seems to be a dead project). I'm using VB .NET 2008 and VS 2008. I've searched all over the MSDN documentation, CodePlex docs (including the Hands-On labs that installed and then vanished), and online tutorials to no avail.
我正在尝试使用 Microsoft 的企业库设置日志记录(log4net 似乎是一个死项目)。我正在使用 VB .NET 2008 和 VS 2008。我搜索了所有 MSDN 文档、CodePlex 文档(包括安装然后消失的动手实验室)和在线教程,但都无济于事。
They all refer to a mysterious "configuration file" or "App.config" that I can't find and can't seem to add. I even tried adding a new text file and renaming it "App.config" but that only made VS 2008 spit out a red wavy line on a blank file.
他们都指的是一个神秘的“配置文件”或“App.config”,我找不到,似乎也无法添加。我什至尝试添加一个新的文本文件并将其重命名为“App.config”,但这只会使 VS 2008 在空白文件上吐出一条红色波浪线。
Any suggestions for finding the elusive app.config would be greatly appreciated.
任何寻找难以捉摸的 app.config 的建议将不胜感激。
(and, if that makes the EntLib configuration tool show up, I'll be absolutely delighted)
(而且,如果这能让 EntLib 配置工具出现,我会非常高兴)
Edit: I've been tricked!
编辑:我被骗了!
The tree in VS 2008 isn't a true superset-subset relationship, which is why I got so frustrated.
VS 2008 中的树并不是真正的超集-子集关系,这就是我如此沮丧的原因。
To wit, the top of the tree: alt text http://static.zooomr.com/images/7954203_910064e809.jpg
也就是说,树的顶部: 替代文字 http://static.zooomr.com/images/7954203_910064e809.jpg
And a 'sub-section' of the tree. alt text http://static.zooomr.com/images/7954204_69e03c8502.jpg
以及树的“子部分”。 替代文字 http://static.zooomr.com/images/7954204_69e03c8502.jpg
回答by cwap
Im pretty sure you can use web.config if youre in a web app or web solution.
如果您在 Web 应用程序或 Web 解决方案中,我很确定您可以使用 web.config。
Otherwise, see here
否则,请参见此处
[EDIT] In my VS the app file can be added like: Add new item -> General -> Application Configuration file
[编辑] 在我的 VS 中,可以添加应用程序文件,例如:添加新项目 -> 常规 -> 应用程序配置文件
回答by smok1
Should be in the same directory as binaries, but you have to add it to your solution first, using Visual Studio window for adding new files to soultion.
应该与二进制文件位于同一目录中,但您必须先将其添加到您的解决方案中,使用 Visual Studio 窗口将新文件添加到 soultion。
Add -> New Item -> Application configuration file
回答by Joseph
You can add an app config file to any vb project by
您可以通过以下方式将应用程序配置文件添加到任何 vb 项目
right clicking on the project -> Add-> New Item -> ...
右键单击项目 -> 添加 -> 新建项目 -> ...
and selecting either
并选择
Application Configuration File
应用程序配置文件
or selecting
或选择
Web Configuration File
网页配置文件
(for app.config or web.config respectively)
(分别用于 app.config 或 web.config)
回答by Tim Coker
Wanted to add my $0.02 as I stumbled on this question with frustrated googling, and my situation wasn't as others have described here. I created a new winforms project, didn't see app.config, and went to add it as others have described. Wasn't in the list. I turned on "Show all files" in Solution Explorer, and it was already there, but not a part of the project. Right clicked on it and selected "Include in project," and now I'm good to go. No idea why it created the file, but didn't include it in the project. (This is VS2010, btw.)
当我通过沮丧的谷歌搜索偶然发现这个问题时,我想添加我的 0.02 美元,而我的情况并不像其他人在这里描述的那样。我创建了一个新的winforms项目,没有看到app.config,然后按照其他人的描述去添加它。不在列表中。我在解决方案资源管理器中打开了“显示所有文件”,它已经存在,但不是项目的一部分。右键单击它并选择“包含在项目中”,现在我可以开始了。不知道为什么它创建了文件,但没有将它包含在项目中。(这是 VS2010,顺便说一句。)