After converting the window service project to .Net 4.0 Framework, you received an error while deploying with InstallUtil Utility or SetUp Project file.
C:\>installutil -i C:\mywindowservice.exe
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.3053
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Jupi
terMobile\JMServerExternalSystem\JMServerExternalSystem.exe' or one of its depen
dencies. This assembly is built by a runtime newer than the currently loaded run
time and cannot be loaded..
If you look closer to InstallUtil output, it displays
“Microsoft (R) .NET Framework Installation utility Version 2.0.50727.3053”
InstallUtil being used here is of Version 2.0. Change the path of InstallUtil to be used from Version 4.0. That should do the trick.
Same goes for SetUp project, Make sure that the initializing assembly is version 4.0. On the Visual Studio SetUp project, Set .Net Framework Launch Conditions to Version 4.0.