using Installutil to install service

cpoDesign picture cpoDesign · Apr 24, 2012 · Viewed 12.6k times · Source

I have WCF service to be installed on windows.

Now I want to install it on a sever running windows and has installed v3.5 .net framework.

It is beside the point that the service has been written in framework 4 and therefor it will not run.

My question is Can I use "installutil" from framework 3.5 to install service and why?

=== UPDATED===

I have windows service that is running wcf inside.

Answer

mundeep picture mundeep · Apr 24, 2012

You use InstallUtil to install a Windows Service. Your WCF Service could have been developed inside a Windows Service if you followed something like the following MSDN article How to: Host a WCF Service in a Managed Windows Service.

However if the (Windows) Service is written in .NET 4 and you try to run installutil from .net 3.5 you will get the following error:

Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\MyService.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..

To install a .NET 4 (Windows) service you will need to use the .NET 4 installutil which will be available in: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe once you have .NET 4 installed.