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

10

10

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.

Shum answered 8/11, 2012 at 20:59 Comment(3)
What platform are you running on, and what arguments are you passing the compiler?Incorporate
I am currently running Windows 8 and trying to test a Windows 8 Store Application. I tried adjust settings and nothing seems to work. I have it set for Any CPUShum
Navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 and type "csc". If that bombs then your machine is messed up.Gordy
B
9

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!

Bluebeard answered 10/11, 2012 at 17:55 Comment(1)
I am guessing this is the problem. Guess I just need to find a csc.exe to replace mine with.Shum
B
6

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".

Basis answered 14/6, 2013 at 11:54 Comment(1)
I know this question is dated already, but I had the same issue with VS2015 and @Waqas Shah's solution was the only one that worked for me. Repairing VS2015 did the trick.Wallop
S
3

I am on Visual Studio 2017 but this is the first google result that pops up for "csc.exe not found"

When I got this error I had to restart Visual Studio, being sure to select 'Run As Administrator'. Everything worked after that

Shenashenan answered 2/11, 2018 at 14:41 Comment(0)
B
1

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.

Barbabas answered 26/4, 2017 at 9:4 Comment(0)
Y
0

Check your solution properties (right-click on Solution and select 'Properties') and make sure that the 'platform' field (Configuration Properties) is set correctly.

Yemane answered 8/11, 2012 at 21:5 Comment(1)
I tried this and nothing seemed to work. Adjusted settings and everything.Shum
T
0

I think this problem is caused due to improper PC clean up. I was running Quick Heal PCTuner 3.0 software on a 64-bit windows 7 machine but suddenly due to loss of power my machine was shut down then when i opened it again I was getting this problem in VS 2013. Even TortoiseSVN checkout was not working and throwing internal error and something like corrupted disk also was shown when trying to delete some files on the harddisk.

I ran the PC Tuner again doing the Disk, Registry and traces clean up and it got fixed. maybe this problem may occur due to other cases also but is mostly related to the system's files In my case this is the fix

Regards.

Torque answered 9/4, 2014 at 10:7 Comment(1)
Guys this is only doing a temporary fix but i had been getting the error again and again day after at times also i was not able to open word documents, join webex calls, or perform some operations on the windows directories so i followed as Bildonia answered and copied someone else's csc.exe into mine and everything seems fine now, Even my app is running better but when this issue occured my app's performance decreased.Torque
B
0

in my case helped (I had .net framework 4.5.1 and vs c# 2010 express): download the newest .net framework and run repair

Bradway answered 5/8, 2014 at 15:53 Comment(0)
E
0

On Visual Studio 2013, the same problem solved by doing this for me: Right click the solution and open Configuration Manager. For the project(you may see at least one there), I've changed the Platform from Any CPU to x86 for the project that may causing the problem.

Eldrida answered 21/12, 2016 at 6:43 Comment(0)
B
0

I've tried to delete and move csc.exe file but it doesn't do anything.

Then simply I upgrade .net version and than downgrade (returned to its original state) and it works.

Breakthrough answered 28/2, 2017 at 15:36 Comment(0)
L
0

I solved my problem by copying the whole folder containing my visual studio solution From C:\Users\me\Google Drive... To: C:\Users\me\OneDrive...

Lawrence answered 2/12, 2018 at 13:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.