8

I have written a Console application that client is trying to run it on their Windows Server 2003 R2 machine machine and they get that error message.

If I go to Build -> Configuration Manager all my projects are set to Platform of "Any CPU" and Configuration of

"Release"

What else I might have missed? They don't want to actually run the console application by double clicking on it, they want to give it to the Windows schedules tasks so it can pick it up and rn it on certain times

Black Frog
  • 11,595
  • 1
  • 35
  • 66
  • 1
    What version of .NET are you targeting? And what version is installed on the server? – Marc Gravell Oct 09 '14 at 12:45
  • @MarcGravell Thanks Mark, I was thinking of the same thing, I "was" by default on 4.5, So now I built it on 4.0 instead and gonna contact the client and see what version they are on? Wnhat is a good way to make sure what version are they on? Ask them to take a screen shot of .NET framework installed from their control panel? – ConfusedSleepyDeveloper Oct 09 '14 at 12:50
  • @ConfusedSleepyDeveloper You can just give your customer a link to the [web installer of v 4.0](http://www.microsoft.com/en-us/download/details.aspx?id=17851) with you program. A better approach is to create a deployment package with ClickOnce or something like InstallShield. The package will check prerequirements and install them if needed. – Diligent Key Presser Oct 09 '14 at 13:01
  • Which version of Visual Studio are you using? And are you using any third-party libaries? – Black Frog Oct 09 '14 at 13:02
  • @BlackFrog I am on VS2012 Professional and I am using EPPlus and Excel.DLL third parties – ConfusedSleepyDeveloper Oct 09 '14 at 13:12
  • Also perform a [dumpbin /headers](http://msdn.microsoft.com/en-us/library/c1h23y6c.aspx) on the executable and the DLL; add the output to your question. – Black Frog Oct 09 '14 at 13:13

1 Answers1

31

Starting with .NET 4.5, the compiler generates an EXE that's marked to be compatible only with Windows version 6.0 and greater. Vista and up. Such an executable will fail to run immediately when started on XP and Server 2003, they are Windows versions 5.0. You get this error before it can tell you that .NET 4.5 isn't installed on the machine.

You must target .NET 4.0 or less. Same requirement on any DLLs you have a dependency on, including unmanaged ones. More about this in this post.

Community
  • 1
  • 1
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Didn't know about Win2003 and its version. Thanks. Hopefully my other third parties be OK or else I" am hosed! I have installed EPPLUS from NUGET – ConfusedSleepyDeveloper Oct 09 '14 at 13:32
  • Ok a question Hans! They sent me the screen shot of their installed .NET and they are on .NET 4.0 "Client Profile"...I have compiled it to "4.0" now ... so is that good or still I should tell them to install full .NET 4.0 ? – ConfusedSleepyDeveloper Oct 09 '14 at 13:51
  • We can only be certain about that if you also compile with the 4.0 Client Profile selected as your framework target. No problems if you get a clean compile. Right now they'll get a prompt to install the full version when they start your program. Maybe you shouldn't fix that :) – Hans Passant Oct 09 '14 at 14:02