0
votes

I am trying to install a windows service with installutil in cmd and this is the msg I get:

Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///D:\inst all\DemoWinProject.exe' or one of its dependencies. The module was expected to contain an assembly manifest..

Can you help me out whats the prb ???

2

2 Answers

2
votes

I have not seen that problem directly, but a very brief search found this link that may have the answer you seek. In a nutshell, make sure you're using the right version of InstallUtil.exe for the .NET framework targeted by your application and that you do not have any x86/x64 inconsistencies within your assemblies.

FWIW, I personally do not like using InstallUtil.exe to install my Windows service; I prefer the Windows service perform its own installation/uninstallation. This is a fairly straightforward thing to do, as I've shown here.

HTH.

0
votes

I fixed this problem by writing the path where my InstallUtil.exe is and then Write the command InstallUtil and then write the path where my exe file that needs to be install is.

Note : Make another copy of debug folder in another place and install the exe file from that path. This is because anytime you make a built the exe file changes.So to prevent the changes of the installed .exe make a copy of it in another place and install it.

ex.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>installutil c:\Documents\Debug\WindowsService.exe