WCF Service as a Windows Service Issue (Windows 7)

I followed the instructions given here to make my existing WCF service (already working perfectly as a console application) also a Windows service on my Windows 7 machine, which is also my development machine.

No matter what I tried, during the last step of using installutil, I get the following message at the command prompt:

An exception occurred while initializing the installation:
System.BadImageFormatException: Failed to load file or assembly 'file: /// [path here]' or one of its dependencies.
An attempt was made to download a program with the wrong format.

I have the main class of my console application that inherits from ServiceBase and implements the OnStart and OnEnd .

I added the ProjectInstaller class of the inheriting System.Configuration.Install.Installer tagged [RunInstaller(true)] attribute and with the code they are in the constructor.

What have I tried, what is not mentioned in the above article?

  1. Run command prompt as administrator
  2. Go to the directory where the EXE file is located and run installutil from there
  3. Providing a strong key to the EXE file and its entire DLL

In addition, I do not get any log file even when specifying it with /LogFile=myLog.txt .

Any ideas are welcome, thanks.

+7
c # wcf windows-services installutil
source share
3 answers

This smells like a 32- / 64-bit issue.

Is your computer 64-bit Windows 7 by accident? Does your service somehow refer to something 32-bit, for example, to an old COM component or something like that?

You may need to compile your stuff using the x86 platform in Visual Studio to make it work correctly ...

+6
source share

BadImageFormat exceptions usually occur when the assembly is loaded into an older version of the .NET framework (assembly 4.0 on a machine without 4.0). Since you are deploying on the same machine, I assume that you are not using the correct version of installutil.

Make sure you use installutil installed here: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

+3
source share

It is beyond me how you can have more ugly children than you when you are ugly to begin with. Isn't that true, my enemy Israhelli? usually children are always prettier ... not your situation

well come on you think you're doing enough? you're so new that you don’t know that I am a shape-changing creature whose entire stack-exchange staff cannot destroy until it gets stronger, right? I’m here over the years and I don’t go anywhere

-one
source share

All Articles