0

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.
VIRIYALA NARESH
  • 187
  • 1
  • 4
  • 17

1 Answers1

0

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 ?

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 30 '22 at 13:22
  • Getting the same error even in DEBUG mode. – VIRIYALA NARESH May 31 '22 at 07:21
  • do you have more informations in the log ? "The file is located at C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog." – DrPingouin May 31 '22 at 11:53
  • the error name a "Path1" variable. is it use in your code and not null ? – DrPingouin May 31 '22 at 11:56
  • In visual studio, do you have projet installer with service process installer and service installer. – DrPingouin May 31 '22 at 12:02