这是我第一次使用 C#,我按照本教程来测试目录监控服务。相关安装步骤在第6步:
http://www.rhyous.com/2012/11/27/c-creating-a-service-to-monitor-a-directory/
Step 6 – Install the Service
Open the Developer Command Prompt by right-clicking and choosing Run as
Administrator.
In the command prompt, change to the bin\debug folder in your project
directory.
Run this command to install the service:
installutil.exe DirectoryMonitoring.exe
Start the service with this command.
net start DirectoryMonitoringService
遵循教程后,我的服务能够在使用 Visual Studio 开发控制台构建后安装和运行。然后我稍微更新了我的代码并再次构建它。
我尝试使用相同的步骤再次通过 VSD 控制台安装或运行该服务,但是当我尝试执行任一命令时出现 Accessed Denied 错误。
我收到以下安装错误:
System.InvalidOperationException: Cannot open Service Control Manager on
computer '.'. This operation might require other priviledges.
The inner exception System.ComponentModel.Win32Exception was thrown with the
following error message: Access is denied.
我还收到以下网络启动错误:
The service name is invalid.
到底是怎么回事?我第一次能够完美地完成所有事情。为什么它现在不起作用?