After converting the window service project to .Net 4.0 Framework, you received an error while deploying with InstallUtil Utility or SetUp Project file.

Error Example:


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.

Happy Coding.

System.BadImageFormatException on WindowService Deployment
Tagged on:     

One thought on “System.BadImageFormatException on WindowService Deployment

  • May 2, 2011 at 3:15 am


    Thanks for the post, it is very helpful, but I still get this error with my setup project. Even thought I set the “Launch condition” to “.Net Framework 4” the setup still tries to install the service with IntallUtil v2.X.

    Do you have any idea for this behavior?

    Thanks in advance.


Leave a Reply

Your email address will not be published. Required fields are marked *