On a C# code, I'm having an error during the installation of a service using installUtil.
I'm using my own installer.
All the code on the installer and the parameters to installUtil are ok, because the installation works ok on 90% of cases.
The failing scenario is under my CI jobs, I'm installing several services in parallel using the same code, and I'm having an impossible to catch exception.
All I have is in logs the following message:
An exception occurred during the Commit phase of the System.Configuration.Install.AssemblyInstaller installer.
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
An exception occurred during the Commit phase of the installation. This exception will be ignored and installation will continue. However, the application might not function correctly after installation is complete.
I have put logs during all phases and method I'm able to override, on my own installer class, also I got some source code of System.Configuration.Install.Installer, I'm logging also there but nothing...
Exception is happening after the Install method and before the Commit.
Just before the execution of Commit phase of System.Configuration.Install.Installer, there is some code with this output:
Logs as follow:
The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file...
Committing assembly ....
Affected parameters are:....
An exception occurred during the Commit phase of the System.Configuration.Install.AssemblyInstaller...
The Commit phase completed successfully.
The transacted install has completed.
An exception occurred during the Commit phase of the installation.
As you can see, exception comes after the Install phase and before the Commit phase, but nowhere on my custom Installer class or on all overridden methods of System.Configuration.Install.Installer
Can anyone give me some hint about how to catch this exception or a better view of the full workflow executed during service install ??
thanks
After look at InstallUtil source code, we have found that the /LogFile parameter, used carefully and in the good place, do the job to have dedicated log file by running instances. in our test scenarios the command line was not well constructed and LogFile param was getting ignored...
Related
Hi all I'm trying to create a VS2015 plugin which will do the Sonarqube analysis as a single step (instead of current three steps) because first step only has the configuration part remaining two steps are common for all the .Net solution.
Software details:
SonarQube v5.6.6
SonarC# v6.0
SonarQube.Scanner.MSBuild v3.0.0
Sonar fxcop v1.0
Scenario:
In my case am calling the pre-process step
(%cd%\SonarQube.Scanner.MSBuild.exe begin /k:"key" /v:"version"
/n:"Name") using "System.Diagnostics.Process" in simple trycatch block. its works fine.
In the System.Diagnostics.Process exit code returns zero & no exception are catched, when pre-process step fails (due to "unhandled exception" or unable to delete some file or some other issue) SonarQube.Scanner.MSBuild.exe log a message as "Pre-processing failed. Exit code: 1" in the logger.
So please suggest me to handle (or catch) the exception in System.Diagnostics.Process or should i use any other approach to handle this case.
I am following the instructions on:
http://msdn.microsoft.com/en-us/library/9k985bc9.aspx - How to create services
http://msdn.microsoft.com/en-us/library/ddhy0byf.aspx - How to: Add Installers to Your Service Application
then I install the service, using an elevated command window and the command installutil.exe -i WindowsService1.exe
This builds, and installs the service and everything perfectly.
However, I would like to add a log to my service, leading me to wanting to create the event log source, and writing an initial message to it in the installer ( as the installer will run with elevated privileges, whereas the actual service might not )
So I add the following to the installer code (projectinstaller.cs)
public ProjectInstaller()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("TestService"))
{
System.Diagnostics.EventLog.CreateEventSource(
"TestService Service", "TestService");
}
System.Diagnostics.EventLog TestEventLog = new System.Diagnostics.EventLog();
TestEventLog.Source = "TestService ServiceInstaller";
TestEventLog.Log = "TestService";
TestEventLog.WriteEntry("New log created");
}
This still builds, but now installutil.exe -i WindowsService1.exe ( still being run with elevated privileges ) throws the following error:
An exception occurred during the Install phase.
System.InvalidOperationException: Unable to create an instance of the WindowsService1.ProjectInstaller installer type.
The inner exception System.Reflection.TargetInvocationException was thrown with the following error message: Exception has been thrown by the target of an invocation..
The inner exception System.ArgumentException was thrown with the following error message: Log TestService has already been registered as a source on the local computer..
Google has lead me to believe that this is some form of permission error with windows RE creating logs, and has led me to a solution that involves manually writing stuff to the registry. I would however prefer to not muck around in the registry if there is a better way to do it ( e.g. a native c# way to get this to work )
How I can register the log and write an initial message to it when installing the service?
The exception is telling you exactly what the problem is. The last line reads:
The inner exception System.ArgumentException was thrown with the following error message:
Log TestService has already been registered as a source on the local computer..
You're trying to create a source that already exists.
See my answer to a similar question for details.
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?
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.
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?
This Problem is due to Security, Better open Command prompt in RUN AS ADMINISTRATOR and install your Service, it fix your problem surely
when i install wcf service hosting on windows service using InstallUtil i get the following Error Message.
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 except
ion will be ignored and the rollback will continue. However, the machine might n
ot 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.
Can You please tell me how to overcome this problem?
Do it as an Admin. I mean to say run a command prompt as an Admin and try. I had the same error and solved using this technique.
There should be more information in the assemblyname.InstallLog file. Check for errors there first.
Check the application event log, run this:
eventvwr.msc
You can see there the details of the real exception your'e getting.
If you're System.ServiceModel settings is in the configuration file, the error you're getting might be because of an invalid configuration settings.
You can follow this tutorial in installing a Managed Windows Service if you're having a hard time in the installation.
I recently tried to change the display name of my windows service, but apparantly I messed up. An old version fails to uninstall completely and I cannot install a new version of the windows service. This is the error generated from running installutil /i myService:
An exception occurred during the uninstallation of the System.Diagnostics.EventLogInstaller installer.
System.InvalidOperationException: The event log source '7 Ac Service' cannot be deleted, because it's equal to the log name.
An exception occurred while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete.
So the event log source is equal to the log name. What does that mean and how do I fix it?
I found out myself. This post helped. So there are basically 3 places in the registry in the same name as the windows service. So I tried first to write a console application to remove the eventlog:
System.Diagnostics.EventLog.Delete("7 Ac Service");
It took care of 2 of them. I removed the last one manually using regedit. Then my windows service installed without problems.