Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 csc.exe Error. Executable not valid for OS

I am getting the following error when trying to compile and test any type of project in Visual Studio 2012 Professional.

Error 1 The specified task executable "Csc.exe" could not be run. The specified executable is not a valid application for this OS platform.

After testing multiple suggestions online nothing has fixed the problem. Anyone know what is causing this? Is there a new version of Csc.exe I need to get a hold of? I know this is the compiler just not sure what I need to do to fix the problem.

like image 454
Greg Froning Avatar asked Nov 08 '12 20:11

Greg Froning


3 Answers

I've faced this problem while i am trying to move Asp.Net Mvc Project from one computer to another ; error message was : The specified task executable location "c:\users\mypcname\documents\visual studio 2015\Projects\TestMVC\packages\Microsoft.Net.Compilers.1.0.0\build\..\tools\csc.exe" is invalid. I solved this by

  1. Creating new Mvc Project ;
  2. going to that folder \Microsoft.Net.Compilers.1.0.0\build..\tools
  3. and Copied the csc.exe file to my Projets >> \Microsoft.Net.Compilers.1.0.0\build..\tools\

i think when i was copying the project from the original Computer i left that csc.exe file in the specified folder.

Hope this will help someone.

like image 195
Mohamed Nor Avatar answered Sep 17 '22 21:09

Mohamed Nor


I had this exact problem today on my Win7 Machine. As Hans suggests, 'Navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 and type "csc".'

The file may still exist but if you can open it with notepad, it will probably show just plain text of some errors. This is the indication that your compiler has been destroyed. At my office we have come up with a theory that a Windows update may be causing this because only a few machines have been affected, but I haven't read much online about it until now.

We fixed this by copying someone else's csc.exe into the C:\Windows\Microsoft.NET\Framework\v4.0.30319 directory and recompiling. Be sure to set the options on the file to read-only so this won't happen again. Good Luck!

like image 9
Bildonia Avatar answered Nov 13 '22 00:11

Bildonia


The problems associated with csc.exe in Visual Studio 2012 can mostly be solved by repairing Visual Studio.

You need to repair Visual Studio. Go to Control Panel -> Programs. Then select your version of Visual Studio you are using and press "Change"(or right click it and press "Change"). When the setup appears, click "Repair".

like image 6
Syed Waqas Avatar answered Nov 12 '22 23:11

Syed Waqas