我正在学习本教程:
http://www.csharp-station.com/Tutorials/Lesson01.aspx
我将其粘贴到一个文本文件中,将其命名为 Welcome.cs:
// Namespace Declaration
using System;
// Program start class
class WelcomeCSS
{
// Main begins program execution.
static void Main()
{
// Write to console
Console.WriteLine("Welcome to the C# Station Tutorial!");
}
}
然后我进入命令提示符,指向文件的目录。我键入 csc.exe Welcome.cs
并收到此错误消息:
csc.exe is not recognized as internal or external command
我正在使用 Visual Studio 2008
我尝试将 csc.exe 移动到 Windows 目录,但现在出现此错误:
fatal error cs2018: unable to find messages file 'cscompui.dll'
如何从命令行编译我的 C# 代码?
最佳答案
csc.exe 不在您的路径中。尝试完全限定它:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe
(当然,用您正在使用的任何框架替换 3.5。)
请注意,此处未使用 Visual Studio。你使用的是什么版本并不重要,因为当你从命令行编译时你没有使用它。命令行编译器是框架本身的一部分。
关于c# - 从命令行编译 C# 代码会出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3425515/