Monday, November 12, 2007

Error during installation of service

The problem:
I tried to create an installer to install a windows service. The two needed installers are the ProcessInstaller and the ServiceInstaller. A requirement was to have a custom Event Log in the system for the service because there are no other ways (as far as I know) to log errors and events of a Windows service. I created therefore a new source and a new log for my application. When I tried then to install the service with "installUtil.exe" I received always an error that the source already exists on the machine and the installation was aborted and rolled back.

The solution:
After some trying I found out, that the ProcessInstaller creates automatically a source in the application log of the computer. As name for the source it uses the name of the project and as I had to realize I used the same name which clearly will produce the error. To solve the issue I created an EventLogInstaller and added it to the list of installers with a different name for the source and another name for the log. This solved all my problems because this installer creates now automatically the log, the source and when deinstalling, everything is removed automatically.
To use the created log the following code can be used:
EventLog.WriteEntry("sourceName", "message");


Juri Strumpflohner said...

Hi :) Cool, seems as if I'm the first to leave a comment on your page. I'm writing in english, so we don't mix up the languages :)
And, everything fine at work??
No, I actually just wanted to ask what kind of tools this "installutil.exe" is and for what purposes it is used.


Manfred said...

Hello :-)
nice that you look at my posts ;-)
At work everything ok, but as you can see I run into many problems...
To your question:
The installutil.exe is a small application which is used to install and uninstall windows services created with visual studio. I think it is included in the .Net framework.