我怎么编译我的App.config到我在VS2010的C#控制台应用程序exe文件? [英] How do I compile my App.config into my exe in a VS2010 C# console app?

查看:696
本文介绍了我怎么编译我的App.config到我在VS2010的C#控制台应用程序exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建在Visual Studio 2010中一个控制台应用程序用C#。我想这个应用程序是独立的,因为所有你需要的是exe文件,你可以在任何地方运行。我也想用的app.config存储连接字符串等。

I'm creating a console app in Visual Studio 2010 with c#. I want this app to be stand alone, in that all you need is the exe, and you can run it from anywhere. I also want to use app.config to store connection strings and so on.

我的问题是,我似乎无法弄清楚如何包含的app.config数据到编译EXE。我看到它创建appname.exe.config,但我不希望人们担心抓两个单独的文件,当他们的应用程序。

My problem is that I can't seem to figure out how to include that app.config data into the compiled exe. I do see it creates appname.exe.config, but I don't want people to have to worry about grabbing two separate files when they get the app.

没有一个谷歌搜索我所做的已经拿出任何东西。这甚至可能?

None of the googling I've done has come up with anything. Is this even possible?

推荐答案

您不能。这种配置文件一半的点是允许应用程序本身之外改变该应用程序的配置。

You can't. Half the point of such config files is to allow changes to the configuration of the app outside of the app itself.

您只会必须修改程序,以便它并没有对应用程序配置文件的相关性 - 最容易做的是只坚持你的配置里面的数值为只读的全局变量的方法

You would simply have to modify your program so that it didn't have a dependency on the app config file -- easiest way to do that would be to just stick the values inside your config into read only global variables.

这篇关于我怎么编译我的App.config到我在VS2010的C#控制台应用程序exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆