How to troubleshoot "CSC is not an internal or external command" in C # compilation

Source: Internet
Author: User

After installing the VisualStudio 2010 compilation environment, it is not possible to compile the CSC file directly with the command line, if the environment variable is not configured, the file with the extension CS is compiled in command prompt (CMD), the error "CSC is not an internal or external command, or a program that can run , or batch file. Then just configure the environment variables, you can successfully execute the CSC command compiled C # source code.

Solution:

Use Notepad to write a C # program, save the extension to CS and store it in the D drive. This file will be a sample in this example. The code is to write "I love u" to the command line.

Find the installation path to the NET Framework, and on the installation path of the. NET Framework, you can see the folders that identify the versions of the. NET Framework that are already installed on this machine, and select the folders that are written with the latest version. If the. NET framework version in this machine is "v4.0.30319" (I am a 64-bit WIN8 operating system, select the directory under Framework64).

After entering the folder, click the upper Address bar with the left mouse button to get the absolute address of the file clip in the system. Copy the address below.

Locate the computer icon on the desktop, right-click, and click Properties in the Pop-up menu. If you don't have the computer icon on your desktop, you can enter "system" in the input box below the Start menu.

After entering the system property settings form, click Advanced System settings on the left, and in the system Properties setting that appears, locate the environment variable in the Advanced tab.

In the "System variables" below, locate the variable "PATH" and click Edit below.

Copy the address you just copied to the end of "PATH". Note If the previous path item already has content, you need to separate the original content with the semicolon ";" in English. When the environment variable is set up, click OK to save and exit the settings screen.

You can now compile the CS file by using the CSC command. After setting the environment variable, CMD needs to be restarted before the CSC command can be executed. After the successful execution, the interface looks like this.

At this point, you can see the compiled executable file on the D drive. The file can be executed correctly.

Precautions

1. The handling of this issue is similar to the process of processing the JAVAC command in Java

2. In general, this type of error message "Not internal or external command" is related to environment variables

How to troubleshoot "CSC is not an internal or external command" in C # compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.