安裝 Visual Studio配置C#開發(fā)環(huán)境
下載軟件
點(diǎn)擊此處開始下載
安裝依賴
選擇.NET desktop development
安裝完成,重啟電腦
手把手教你解決異常couldnt install microsoft.visualcpp.redist.14
Something went wrong with the install.
You can troubleshoot the package failures by:
1. Search for solutions using the search URL below for each package failure
2. Modify your selections for the affected workloads or components and then retry the installation
3. Remove the product from your machine and then install again
If the issue has already been reported on the Developer Community, you can find solutions or workarounds there. If the issue has not been reported, we encourage you to create a new issue so that other developers will be able to find solutions or workarounds. You can create a new issue from within the Visual Studio Installer in the upper-right hand corner using the "Provide feedback" button.
================================================================================
Package 'Microsoft.VisualCpp.Redist.14,version=14.38.33130,chip=x86' failed to install.
Search URL
https://aka.ms/VSSetupErrorReports?q=PackageId=Microsoft.VisualCpp.Redist.14;PackageAction=Install;ReturnCode=-2147023274
Details
Command executed: "c:\windows\syswow64\\windowspowershell\v1.0\powershell.exe" -NoLogo -NoProfile -Noninteractive -ExecutionPolicy Unrestricted -InputFormat None -Command "& """C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14,version=14.38.33130,chip=x86\VCRedistInstall.ps1""" -PayloadDirectory """C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14,version=14.38.33130,chip=x86""" -Architecture x86 -Logfile """C:\Users\XX\AppData\Local\Temp\dd_setup_20240119115035_255_Microsoft.VisualCpp.Redist.14.log"""; exit $LastExitCode"
Return code: -2147023274
Return code details: Error opening installation log file. Verify that the specified log file location exists and that you can write to it.
Log
解決方案1
- 找到這個(gè)目錄C:\ProgramData\Microsoft\VisualStudio\Packages
- 直接搜索VC_redist關(guān)鍵詞
- 找到這個(gè)VC_redist.x64.exe文件,一般會(huì)有兩個(gè),直接全部雙擊安裝
- 返回VS installer 界面點(diǎn)擊:更多—修復(fù)
解決方案2
- 當(dāng)遇到報(bào)錯(cuò),點(diǎn)擊錯(cuò)誤信息下面的查看日志選項(xiàng),打開日志文件(就像上面粘貼的那些異常信息)
- 在錯(cuò)誤日志中尋找安裝文件的路徑,類似于:C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft. visualcp . redist .14. latest,version=xx.xx.xxxxx
- 打開此路徑位置
- 看到一個(gè)VC redist.xxx.exe
- 安裝運(yùn)行它
- 關(guān)機(jī)重啟
- 重新運(yùn)行VS installer 界面點(diǎn)擊:更多—修復(fù)
創(chuàng)建第一個(gè)C#程序
創(chuàng)建項(xiàng)目
- 啟動(dòng) Visual Studio;
- 在菜單欄上依次選擇“文件”->“新建”->“項(xiàng)目”;
- 從模板中選擇“Blank Solution”,然后點(diǎn)擊“下一步”;
- 指定項(xiàng)目名稱等信息,然后單擊“創(chuàng)建”按鈕;
- 在右側(cè)項(xiàng)目空白處,右鍵新建文件,名字為‘hello.cs’
編寫代碼
using System;
namespace c.biancheng.net
{
class Program
{
static void Main(string[] args)
{
/*第一個(gè)C#程序*/
Console.WriteLine("Hello World!");
Console.ReadKey();
}
}
}
配置環(huán)境
若提示無(wú)法識(shí)別 csc 命令,需C#命令行編譯環(huán)境變量(Window10)
- 打開計(jì)算機(jī),右鍵單擊
- 屬性-高級(jí)系統(tǒng)設(shè)置-環(huán)境變量-系統(tǒng)變量
- 找到變量 Path, 添加路徑 (可以打開路徑看一下,盡量選擇最新版本進(jìn)行添加)
- 多個(gè)環(huán)境變量使用;分隔
C:\Windows\http://Microsoft.NET\Framework\v版本號(hào)
運(yùn)行
-
打開 CMD 命令行工具,cd 進(jìn)入 hello.cs 文件所在目錄
-
在命令行工具中輸入csc hello.cs,回車(此步驟需要電腦有csc 命令環(huán)境)
-
當(dāng)前目錄自動(dòng)生成 hello.exe可執(zhí)行文件
-
命令行工具輸入hello 或 hello.exe 或雙擊運(yùn)行 hello.exe
-
我們就可以看到屏幕輸出“Hello World!”啦~
-
今天就寫到這里啦~
-
小伙伴們,( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ我們明天再見(jiàn)啦~~
-
大家要天天開心哦
歡迎大家指出文章需要改正之處~
學(xué)無(wú)止境,合作共贏文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-858854.html
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-858854.html
歡迎路過(guò)的小哥哥小姐姐們提出更好的意見(jiàn)哇~~
到了這里,關(guān)于C#系列-手把手教你安裝 Visual Studio配置C#開發(fā)環(huán)境,創(chuàng)建第一個(gè)C#程序的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!