wpf .net core win7 独立运行补丁安装记录
Windows 7 系统上,根据 dotnet 官方文档,需要安装上 KB2533623 补丁
方案如下:
首先使用 fx 2.0 写一个启动器 如果检测可以运行则拉起.net core 主程序 否则弹出命令行提示安装补丁
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | using PInvoke; using System; using System.Diagnostics; using System.Windows.Forms; namespace netcorefix { class Program { static void Main( string [] args) { using ( var hModule = Kernel32.LoadLibrary( "Kernel32.dll" )) { if (!hModule.IsInvalid) { IntPtr hFarProc = Kernel32.GetProcAddress(hModule, "AddDllDirectory" ); if (hFarProc != IntPtr.Zero) { Console.WriteLine( "Either running on Win8+, or KB2533623 is installed" ); } else { Console.Write( "Likely running on Win7 or older OS, and KB2533623 is not installed" ); Process proc = new Process(); proc.StartInfo.FileName = "installpack.bat" ; proc.Start(); proc.WaitForExit(); MessageBox.Show( "修补完成请重启电脑" ); } } } // 以下是判断 Universal C Runtime 的逻辑,可以忽略 using ( var hModule = Kernel32.LoadLibraryEx( "UCRTBASE.dll" , IntPtr.Zero, Kernel32.LoadLibraryExFlags.LOAD_LIBRARY_SEARCH_SYSTEM32)) { if (!hModule.IsInvalid) { Console.WriteLine( "UCRT is available - Either running on Win10+ or KB2999226 is installed" ); } else { Console.WriteLine( "UCRT is not available - Likely running on OS older than Win10 and KB2999226 is not installed" ); } } } } } |
2、创建一个bat文件将以下命令复制到bat里 补丁放在同一个目录
1 2 3 4 5 6 7 8 9 | echo 正在安装补丁请稍后.... cd /d %~dp0 wmic qfe GET hotfixid | findstr /C: "KB2533623" if %errorlevel% equ 0 (Echo Patch KB2533623 installed) else ( wusa Windows6.1-KB2533623-x64.msu /quiet /norestart wusa Windows6.1-KB2533623-x86.msu /quiet /norestart exit /b 1 ) exit /b 0 |
本文转自:https://blog.lindexi.com/post/%E6%8E%A2%E7%B4%A2-dotnet-core-%E4%B8%BA%E4%BD%95%E5%9C%A8-Windows7-%E7%B3%BB%E7%BB%9F%E9%9C%80%E8%A6%81%E8%A1%A5%E4%B8%81%E7%9A%84%E5%8E%9F%E5%9B%A0.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗