Windows服务配置文件C# [英] Windows Service Config File C#

查看:1149
本文介绍了Windows服务配置文件C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发使用Visual Studio Windows服务应用程序2008 / C#。

I've developed a windows service application using Visual Studio 2008 / C#.

我在该项目中的app.config文件。安装时,app.exe.config文件出现在旁边的可执行文件,但它似乎当我试图通过ConfigurationManager.AppSettings访问它们不被读取从它的值。

I have an app.config file in the project. When installed, the app.exe.config file appears beside the executable but it appears not to be reading the values from it when I try to access them through ConfigurationManager.AppSettings.

有它在其他地方复制配置文件或者是有一些其他的问题,我不知道?

Has it copied the config file elsewhere or is there some other problem I don't know about?

由于提前,

马丁。

编辑:
配置文件名INFACT my_exe_file_name.exe.config,它看起来像:

The config file name is infact my_exe_file_name.exe.config, it looks like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>

    <add key="RuntimeFrequency" value="3" />

  </appSettings>
</configuration>

和我想通过阅读:

ConfigurationManager.AppSettings["RuntimeFrequency"]

调试值我不断看到的是'1',而不是'3'。难道我做错了吗?

The debug value I continually see is '1' and not '3'. Am I doing something wrong here?

推荐答案

我所在的错误,这是有关文件的权限。安装服务后,我的本地用户帐户没有获得修改app.exe.config文件。

I located the error and it was related to file permissions. After installing the service, my local user account didn't have access to modify the app.exe.config file.

我用编辑的工具是不是通知我它被拒绝访问保存文件 - 这是记事本+ +如果有人有兴趣 - 所以我看不出它不保存在旧的配置文件

The tool I was using to edit was not informing me it was being denied access to save the file - that's notepad++ if anyone is interested - so I couldn't see that it wasn't saving over the old config file.

现在解决了,谢谢大家。

Solved now, thanks everyone.

马丁。

这篇关于Windows服务配置文件C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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