VisualStudioLogo

Visual Studio 2012 C# x86 console application

posted in: c#, VS2012 | 0

Just a quick post to help anyone else in the same situation…

I needed to write a simple console application in C# (to receive serial data and save it to a file), but found that when I copied the application to the Windows XP (SP2) target machine, that it didn’t run and I got the “Not a valid Win32 Application” error message.

Searching on the web I found numerous postings about how Visual Studio 2012 could no longer target XP, but that VS2012 Update 1 had a fix for this, in the project configurations. But these config’s are not present on a C# build and seem to be specific to C++.

Anyway, the actual solution was to change the CPU type from “Any” to X86 (my target machine is X86), and this changed the error on the XP machine to an error for not having .Net 4.5 installed.

But .Net 4.5 was not available for XP at the time of writing, and the machine already had .Net 4.0 installed.

However switching the VS project to use .Net 4 didn’t immediately appear to fix the problem, until I realised that it was necessary to completely quit VS and restart it, in order for the settings changes to the project to be registered. (VS closes and re-opens the project when you change .Net versions, but this doesn’t seem to reset everything in VS2012 (update 2)).

Anyway, I finally got the app working on target machine.