Search code examples
c#visual-studio-2010windows-servicescompatibility

New Version Error C#


I've built a windows service code with Framework Verison 4.0, when I sent my service.exe for instllation at different machine which has version 2.0 installed it gave error:

"Exception occurred while initializing installation:

System.BadImageFormatException: couls not load file or assembly '\service.exe' or one of its dependencies. This assembly is built by a runtime newer than currently loaded runtime and cannot be loaded"

How can I build a service which is backward compatible in visual studio


Solution

  • Change your target framework to 2.0, and make sure you do not use anything that's not part of 2.0 (e.g. TPL, etc), otherwise, install .NET 4 on the target machines

    enter image description here