C# を使用するのはこれが初めてで、Directory Monitoring Service をテストするためにこのチュートリアルに従っていました。関連するインストール手順は手順 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.
何が起こっている?初めてすべてを完璧にこなすことができました。なぜ今それが機能していないのですか?