From Hans Passant in comment,
The setting that actually matters is Project > Properties > Build > "Platform target"
I said in the question there was no use of AnyCpu but this was false when I checked these settings for the project.