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?
Also, I don't get any log file even when specifying it with /LogFile=myLog.txt
.
Any ideas are welcome, thanks.
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.
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.
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.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With