Search code examples
windows-servicesserviceinstallutilbadimageformatexception

InstallUtill of GCC compiled .exe receiving System.BadImageFormatException


I am trying to use a GCC compiled .exe as a service in windows. From what I have researched I should do:

 C:\Windows\Microsoft.net\Framework\v2.0.50727\InstallUtil.exe [program name] 

Although when I try to do this I receive a message as such:

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\Chris\Documents\Visual Studio 2010\Projects\Setup4\Setup4\Service.exe' or one of its dependencies. The module was expected to contain an assembly manifest..

I have a feeling that this is due to the fact that the program was compiled using GCC and did use some .a files to compile.

From what I see System.BadImageFormatException is usually caused by some sort of bad manifest. Would someone be able to help me out here?


Solution

  • InstallUtil is used to install .Net applications as services. Unless GCC can produce managed assemblies, you should be using sc.exe instead to create a Windows service entry for your application.