c#Windows服务是否可以使用app.config [英] c# Windows service is it (possible) to use the app.config

查看:49
本文介绍了c#Windows服务是否可以使用app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows服务,我快完成了,

I am developing a windows service, and I am almost done,

我正在使用Visual Studio 2012.

I am doing that using Visual Studio 2012.

我连接到 App.config 文件以读取连接字符串,因为Windows服务处理数据库中安装的数据.

I am connection to the App.config file in order to read the connection string because the windows service deals with data installed in a database.

我可以在计算机上安装此Windows服务,但是我问该服务在安装后是否仍然能够从 App.config 中读取?还是我必须对连接字符串进行硬编码?

I am able to install this Windows service on my machine, but I am asking if this service will still be able to read from the App.config after being installed? or I must hard coded the connection string?

我希望我能解释我的问题.但是,如果您不了解我,请告诉我更多信息.

I hope I was able to explain my problem. However, If you dont' understand me, please tell me to inform you more.

最好的问候

推荐答案

是的,您将可以.编译服务时,需要部署整个/bin 目录.它将包含服务依赖关系和实际代码.

Yes you will be able. When you will compile your service, you will need to deploy the whole /bin directory. It will contains the service dependencies and actual code.

编译后, App.config 文件将重命名为: Service.exe.config .内容将是 App.config 的副本.这是服务将使用的文件. Service.exe 是可执行文件的名称.因此,如果您的可执行文件是 AwesomeService.exe ,则配置文件将是 AwesomeService.exe.config .

Once compiled, the App.config file will be renamed to: Service.exe.config. The content will be a copy of the App.config. This is the file that will be used by the service. Service.exe is the name of your executable. So if your executable is AwesomeService.exe the config file will be AwesomeService.exe.config.

这篇关于c#Windows服务是否可以使用app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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