Windows服务app.config位置 [英] Windows service app.config location

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

问题描述

我已经在Windows Server 2008上安装了C#Windows服务。我通过InstallUtil安装了它。该服务从app.config文件中读取了一些数据,并且一切正常。安装服务后,您能否告诉我该文件的位置?
我一直在找几个小时,但是找不到。

I have installed a C# Windows Service on Windows Server 2008. I installed it with InstallUtil. The service reads some data from the app.config file and it is doing it fine. Can you tell me where this file is located after installing the service? I have been looking for hours but can't find it.

推荐答案

您可以验证确切的位置请按照以下步骤安装Windows服务:

You can verify the exact location of the installed Windows Service by following the steps below:


  1. 通过单击Windows服务列表下的服务图标来显示Windows服务列表。 管理工具图标。您还可以通过在开始菜单下的搜索菜单中键入查看本地服务来获得此列表。

  1. Bring up the list of Windows Services by clicking the "Services" icon under the "Administrative Tools" icon. You can also get this list by typing "View local services" in the Search Menu under the Start Menu.

在已安装服务的列表中选择Windows服务。 ,单击鼠标右键,然后选择属性。您也可以双击代表服务的行。

Select your Windows service in the list of installed services, right-click and then select Properties. You can also double click on row representing the service.

在属性对话框中找到可执行文件的路径值。该值将包含任何命令行参数。

Locate the "Path to executable" value on the Properties dialog box. The value will include any command line parameters.

打开服务可执行文件所在的文件夹。

Open the folder in which the service executable resides.

如果Windows服务是使用.NET Framework构建的,则其配置将存储在相应的.config文件中,即,后缀为 .config的可执行文件的名称。例如,如果可执行文件的名称是 XyzService.exe,那么.config文件的名称将是 XyzService.exe.config。

If the Windows service has been built with .NET Framework, its configuration will be stored in the corresponding .config file, i.e., the name of the executable suffixed by ".config", e.g., if the name of the executable is "XyzService.exe", then the name of the .config file will be "XyzService.exe.config".

需要注意的几件事:


  • 如果您在使用Visual Studio在同一台机器上构建服务后安装了该服务,那么Visual Studio将从项目中转换App.config文件并将其自动放置在生成输出文件夹中(并使用上述命名约定对其进行了适当的重命名)。

  • If you installed the service after building it on the same machine using say, Visual Studio, then Visual Studio would have transformed the App.config file from the project and placed it in the build output folder automatically (and renamed it appropriately using the above naming convention).

如果您的计算机设置为在Windows资源管理器中隐藏文件扩展名,则将看到2个文件 XyzService和 XyzService.exe。在这种情况下, XyzService.exe是您的配置文件。如果然后关闭在Windows资源管理器中隐藏文件扩展名的选项,那么您将开始看到 XyzService.exe和 XyzService.exe.config。

If your machine is set to hide file extensions in Windows Explorer, you will see 2 files "XyzService" and "XyzService.exe". In this case, the "XyzService.exe" is your config file. If you then switch off the option to hide file extenions in Windows Explorer, you will then begin to see "XyzService.exe" and "XyzService.exe.config".

如果找不到对应的.exe.config文件,则该服务中的代码可能会回退到默认值。在这种情况下,您可以在服务可执行文件旁边放置一个正确命名和格式化的配置文件,然后重新启动服务,一切都会好起来。

If you cannot find a corresponding .exe.config file, then it is possible that the code within the service is falling back to default values. In this case, you can place a properly named and formatted config file alongside the service executable and then restart the service and everything should be fine.

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

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