11

I created a C# service. Now I want to install that service on Windows Server 2008 R2. I am using the InstallUtil command to install the service. I opened the command prompt as an admin.

The service should run as a certain user, therefore I set the account to user on the Service Installer.

When I run the command I get an error:

An exception occured during the Install phase: System.ComponentModel.Win32Exception: Access Denied.

Here is the log file:

Installing assembly 'C:\Service\MyService.exe'. Affected parameters are: logtoconsole = logfile = C:\Service\MyService.InstallLog assemblypath = C:\Service\MyService.exe Rolling back assembly 'C:\Service\MyService.exe'. Affected parameters are: logtoconsole = logfile = C:\Service\MyService.InstallLog assemblypath = C:\Service\MyService.exe An exception occurred during the Rollback phase of the System.ServiceProcess.ServiceProcessInstaller installer. System.NullReferenceException: Object reference not set to an instance of an object. An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete. 

Here is what is displayed on the command prompt:

Beginning the Install phase of the installation. See the contents of the log file for the C:\Service\MyService.exe assembly's progress. The file is located at C:\Service\MyService.InstallLog. Installing assembly 'C:\Service\MyService.exe'. Affected parameters are: logtoconsole = logfile = C:\Service\MyService.InstallLog assemblypath = C:\Service\MyService.exe An exception occurred during the Install phase. System.ComponentModel.Win32Exception: Access Denied at System.ServiceProcess.ServiceProcessInstaller.OpenSecurityPolicy() at System.ServiceProcess.ServiceProcessInstaller.Install(IDictionary stateSaver) at System.Configuration.Install.Installer.Install(IDictionary stateSaver) at System.Configuration.Install.Installer.Install(IDictionary stateSaver) at System.Configuration.Install.AssemblyInstaller.Install(IDictionary savedState) at System.Configuration.Install.Installer.Install(IDictionary stateSaver) at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState) The Rollback phase of the installation is beginning. See the contents of the log file for the C:\Service\MyService.exe assembly's progress. The file is located at C:\Service\MyService.InstallLog. Rolling back assembly 'C:\Service\MyService.exe'. Affected parameters are: logtoconsole = logfile = C:\Service\MyService.InstallLog assemblypath = C:\Service\MyService.exe An exception occurred during the Rollback phase of the System.ServiceProcess.Ser viceProcessInstaller installer. System.NullReferenceException: Object reference not set to an instance of an obj ect. An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete. The Rollback phase completed successfully. The transacted install has completed. The installation failed, and the rollback has been performed. 

Does somebody know what I need to do to install the service?

11
  • do you have custom code in isntaller? Commented Mar 11, 2013 at 10:02
  • There is no custom code in the installer. Commented Mar 11, 2013 at 10:04
  • I have now created a new empty service project in Visual Studio and tried to install that service on the server. I got the same error. Commented Mar 11, 2013 at 10:11
  • Did you start up command prompt with elevated permissions? The Run as Admin option when you right click it. Commented Mar 11, 2013 at 10:22
  • 1
    Yes I opened the command prompt with elevated permissions. Commented Mar 11, 2013 at 10:26

4 Answers 4

9

I finally could install the service. I was logged into the server in a role called server admin. My Administrator added my account to the local administrators group of the server. After this I could install the service. It seams like the server Admin account, that I used to log into the system did not have full admin priviledges.

Thanks for your help.

Sign up to request clarification or add additional context in comments.

Comments

2

You really didn't give any details as to what your service does and I am unable to comment direct on your post yet but you might try this link

The summary of this is to check and make sure you are running the proper 32/64 bit installutil.exe and to verify your merge module are not causing the issue.

Perhaps a better description of your service would help? Does the service install fine on your local machine as opposed to the server?

Comments

1

This Problem is due to Security, Better open Command prompt in RUN AS ADMINISTRATOR and install your Service, it fix your problem surely

Comments

0

Basically, it will be resolved in two steps:

  1. At first, Copy/Paste the DEBUG folder of your project file—this will be available in /bin—into some other folder (say, D:\Debug)

  2. Run the below command at the CMD prompt:

    cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 
  3. Finally, create the service using:

    sc create "ServiceName" binpath="D:\P1\Debug\ServiceName.exe" 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.