Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service as Windows Service woes (Windows 7)

I followed the steps here to make my existing WCF service (already working fine as console application) be Windows Service as well, on my Windows 7 machine which is also my development machine.

No matter what I tried, when doing the last step of using installutil, I'm getting the following message in the command line:

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///[path here]' or one of its dependencies.
An attempt was made to load a program with an incorrect format..

I have my console application main class inherit from ServiceBase and implement OnStart and OnEnd methods.

I have added ProjectInstaller class inheriting from System.Configuration.Install.Installer marked with [RunInstaller(true)] attribute and with the code they supplied in the constructor.

What I already tried that is not mentioned in the above article?

  1. Running the command line as administrator
  2. Navigating to the directory where the EXE file is located and running installutil from there
  3. Giving strong key to the EXE file and all DLL's it's using

Also, I don't get any log file even when specifying it with /LogFile=myLog.txt.

Any ideas are welcome, thanks.

like image 860
Shadow Wizard Hates Omicron Avatar asked Oct 25 '10 16:10

Shadow Wizard Hates Omicron


People also ask

What is difference between Windows service and WCF service?

A windows service is what you need. WCF is a communications library, and unless you plan to communicate with your application via a client, you don't need it. Your problem is related to activation, and keeping your code active in the background is what windows services do.

Why do we need WCF service?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

What is SVC file in WCF?

A . svc file contains a WCF-specific processing directive (@ServiceHost) that allows the WCF hosting infrastructure to activate hosted services in response to incoming messages. The most common syntax for a . svc file is in the following statement.

What are 3 basic WCF configuration required for hosting a WCF service?

There are three types of hosting environments for WCF services: IIS, WAS, and self-hosting. The term “self-hosting” refers to any application that provides its own code to initialize the hosting environment. This includes console, Windows Forms, WPF, and managed Windows services.


1 Answers

That smells like a 32-/64-bit problem.

Is your machine 64-bit Windows 7 by any chance?? Does your service somehow reference something 32-bit , like an old COM component or something??

You might need to compile your stuff with the x86 platform in Visual Studio to get it to work properly...

like image 119
marc_s Avatar answered Sep 18 '22 14:09

marc_s