Trying to run on W7 64-bits, using .Net 3.5 on Visual C# 2008 Express, I tried running installutil.exe in Framework and Framework64 folder, both throw the same error. 3.5 folder doesn't have installutil.exe and 4.0 in both folders doesn't work too.
In IDE, there is no Release build but Publish, are they the same?
I follow the tutorial from this article: http://www.switchonthecode.com/tutorials/creating-a-simple-windows-service-in-csharp
What could be wrong?
D:\install>C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe setup.e
xe
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///D:\inst
all\setup.exe' or one of its dependencies. The module was expected to contain an
assembly manifest..
The System.BadIMageFormatException normally occurs when you try to load a 64bit assembly or native dll in a 32bit context or vice-versa.
If you are running on a 64bit version of windows there is also a directory c:\windows\Microsoft.Net\Framework64\. Try the installutil that you find in one of the subdirectories there.
Another possible problem is that you are running InstallUtil against the wrong assembly (.exe or .dll). You are running it against setup.exe. In the tutorial that you are referring to there is no explicit setup program. InstallUtil is ran against MyWindowsService.exe. In the tutorial you create a program that uses the System.Configuration.Install namespace. InstallUtil uses the attribute [RunInstaller(true)] from that namespace to find ´installation instructions´ in an assembly, so there is no need for a seperate installer program (setup.exe).
Have you tried following the tutorial to the letter first and then extend it with your own code?
The same problem you get when building windows service in .NET 4 and trying install with installutil.exe from .NET v2 directory. You must use installutil.exe from .NET v4 directory (Windows/Microsoft .NET/Framework/v4.0.30319/installutil.exe)
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