C# Visual Studio 2012 csc.exe 错误。可执行文件对操作系统无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13297704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2012 csc.exe Error. Executable not valid for OS
提问by Greg Froning
I am getting the following error when trying to compile and test any type of project in Visual Studio 2012 Professional.
尝试在 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.
错误 1 无法运行指定的任务可执行文件“Csc.exe”。指定的可执行文件不是此操作系统平台的有效应用程序。
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.
在在线测试了多个建议后,没有任何解决问题的方法。有谁知道是什么原因造成的?是否需要获取新版本的 Csc.exe?我知道这是编译器,只是不确定我需要做什么来解决问题。
采纳答案by Bildonia
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".'
我今天在我的 Win7 机器上遇到了这个确切的问题。正如汉斯所建议的,“导航到 C:\Windows\Microsoft.NET\Framework\v4.0.30319 并输入“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.
该文件可能仍然存在,但如果您可以用记事本打开它,它可能只会显示一些错误的纯文本。这表明您的编译器已被破坏。在我的办公室,我们提出了一个理论,即 Windows 更新可能会导致这种情况,因为只有少数机器受到影响,但直到现在我还没有在网上阅读太多关于它的信息。
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!
我们通过将其他人的 csc.exe 复制到 C:\Windows\Microsoft.NET\Framework\v4.0.30319 目录并重新编译来解决此问题。请务必将文件上的选项设置为只读,以免再次发生这种情况。祝你好运!
回答by David
Check your solution properties (right-click on Solution and select 'Properties') and make sure that the 'platform' field (Configuration Properties) is set correctly.
检查您的解决方案属性(右键单击解决方案并选择“属性”)并确保“平台”字段(配置属性)设置正确。
回答by Syed Waqas
The problems associated with csc.exe in Visual Studio 2012 can mostly be solved by repairing Visual Studio.
Visual Studio 2012 中 csc.exe 相关的问题大多可以通过修复 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".
您需要修复 Visual Studio。转到控制面板->程序。然后选择您正在使用的 Visual Studio 版本并按“更改”(或右键单击它并按“更改”)。出现设置时,单击“修复”。
回答by Mohammed Abdul Mateen
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.
我认为这个问题是由于 PC 清理不当造成的。我在 64 位 Windows 7 机器上运行 Quick Heal PCtuner 3.0 软件,但突然由于断电,我的机器被关闭,然后当我再次打开它时,我在 VS 2013 中遇到了这个问题。即使 TortoiseSVN 结帐也不起作用,并且尝试删除硬盘上的某些文件时,还会显示抛出内部错误和磁盘损坏之类的内容。
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
我再次运行 PC Tuner 进行磁盘、注册表和痕迹清理,它得到了修复。也许这个问题也可能由于其他情况而发生,但主要与系统文件有关在我的情况下这是修复
Regards.
问候。
回答by bez
in my case helped (I had .net framework 4.5.1 and vs c# 2010 express): download the newest .net framework and run repair
在我的情况下有帮助(我有 .net framework 4.5.1 和 vs c# 2010 express):下载最新的 .net 框架并运行修复
回答by Gurer Onder
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 CPUto x86for the project that may causing the problem.
在 Visual Studio 2013 上,通过为我执行此操作解决了同样的问题:右键单击解决方案并打开配置管理器。对于该项目(您可能至少会在那里看到一个),对于可能导致问题的项目,我已将平台从Any CPU更改为x86。
回答by NeshaSerbia
I've tried to delete and move csc.exe file but it doesn't do anything.
我试图删除和移动 csc.exe 文件,但它没有做任何事情。
Then simply I upgrade .net version and than downgrade (returned to its original state) and it works.
然后我只需升级 .net 版本而不是降级(返回到其原始状态)并且它可以工作。
回答by Mohamed Nor
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 solvedthis by
我在尝试将 Asp.Net Mvc 项目从一台计算机移动到另一台计算机时遇到了这个问题;错误消息是: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.
我解决了这个问题
- Creating new Mvc Project ;
- going to that folder \Microsoft.Net.Compilers.1.0.0\build..\tools
- and Copied the csc.exe file to my Projets >> \Microsoft.Net.Compilers.1.0.0\build..\tools\
- 创建新的 Mvc 项目;
- 转到该文件夹 \Microsoft.Net.Compilers.1.0.0\build..\tools
- 并将 csc.exe 文件复制到我的 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.
我想当我从原始计算机复制项目时,我将该 csc.exe 文件留在了指定的文件夹中。
Hope this will help someone.
希望这会帮助某人。
回答by N0ug4t
I am on Visual Studio 2017 but this is the first google result that pops up for "csc.exe not found"
我在 Visual Studio 2017 上,但这是第一个弹出“找不到 csc.exe”的谷歌结果
When I got this error I had to restart Visual Studio, being sure to select 'Run As Administrator'. Everything worked after that
当我收到此错误时,我必须重新启动 Visual Studio,并确保选择“以管理员身份运行”。之后一切正常
回答by Felix Augustin
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...
我通过从 C:\Users\me\Google Drive... 复制包含我的 Visual Studio 解决方案的整个文件夹来解决我的问题:C:\Users\me\OneDrive...

