Error on Creating EventLog source with windows service installation

523 Views Asked by At

I have developed a windows service in c#, The project works fine in DEBUG mode, also the project is built with out any errors. When I try to install the service using InstallUtil.exe, I get below error and the service is not installed. Could someone please help what is going wrong here.

Installation command

  1. Open command prompt in admin mode
  2. Navigate to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
  3. Run below command
    installutil.exe C:\Users\Public\TestService\MyService\bin\Release\MyService.exe

Error

Creating EventLog source MyService in log Application...
An exception occurred during the Install phase.
System.Exception: Value cannot be null.
Parameter name: path1

Below is the complete installation log.

Microsoft (R) .NET Framework Installation utility Version 4.8.4161.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\Users\Public\TestService\MyService\bin\Release\MyService.exe assembly's progress.
The file is located at C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog.
Installing assembly 'C:\Users\Public\TestService\MyService\bin\Release\MyService.exe'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\Users\Public\TestService\MyService\bin\Release\MyService.exe
   logfile = C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog
Installing service MyService...
Service MyService has been successfully installed.
Creating EventLog source MyService in log Application...

An exception occurred during the Install phase.
System.Exception: Value cannot be null.
Parameter name: path1

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\Users\Public\TestService\MyService\bin\Release\MyService.exe assembly's progress.
The file is located at C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog.
Rolling back assembly 'C:\Users\Public\TestService\MyService\bin\Release\MyService.exe'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\Users\Public\TestService\MyService\bin\Release\MyService.exe
   logfile = C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog
Restoring event log to previous state for source MyService.
Service MyService is being removed from the system...
Service MyService was successfully removed from the system.
Attempt to stop service MyService.

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.
1

There are 1 best solutions below

5
On

did you try to go into your path : C:\Users\Public\TestService\MyService\bin\Release (if you built in debug use the debug folder)

and here, use command : installutil MyService.exe

You said the projet work well in debug mode. can you install it in debug ?