我在Windows服务中收到一个system.configuration.settingspropertynotfoundexception错误

编程入门 行业动态 更新时间:2024-10-10 17:25:40
本文介绍了我在Windows服务中收到一个system.configuration.settingspropertynotfoundexception错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个Windows应用程序,该应用程序使用SettingsProvider读取配置设置,并在文件不存在的情况下设置默认值.

I have a windows app that uses SettingsProvider to read configuration settings and sets default values if file does not exist.

正常运行可以正常工作.

It works fine running normally.

我正在尝试编写启动该应用程序的Windows服务.当它由服务运行时,我在所有设置属性上都得到System.Configuration.SettingsPropertyNotFoundException.

I am trying to write a windows service that starts this app. When it is run by the service, I get System.Configuration.SettingsPropertyNotFoundException on all the setting attributes.

当服务运行应用程序时,如何解决此异常?

How can I resolve this exception when the service is running the app?

推荐答案

这仅表示该应用无法读取.Settings文件.我可以想到两个可能的原因:

This simply means that the app can't read the .Settings file. I can think of two possible causes:

  • 该服务在无法访问.settings文件的帐户下运行. (或.config文件,视情况而定),这不太可能,因为该服务可以启动应用程序,并且对应用程序而不是设置文件具有权限是没有意义的.

  • The service runs under an account that doesn't have access to the .settings file. (or .config file, depending) This is unlikely because the service can start the app, and it wouldn't make sense for it to have permissions to the app and not the settings file.

    运行时无法找到设置文件.它期望设置位于可执行文件的根启动路径中.检查并确保问题机器上存在该机器.

    The runtime can't find the settings file. It expects the settings to be in the root startup path of the executable. Check to ensure that it exists on the machine in question.

    但是,谷歌搜索结果显示出一个我可能没有想到的明显原因.上次编译后是否添加了.settings?在Visual Studio中编译该应用,然后重试...

    However, a google result turned up an obvious possible cause I haven't thought of. Were the .settings added after the last compile? Compile the app in Visual Studio, and try again...

  • 更多推荐

    我在Windows服务中收到一个system.configuration.settingspropertynotfoundexception错误

    本文发布于:2023-11-08 20:53:41,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1570431.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:我在   错误   Windows   system   configuration

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!