首页 > 其他分享 >wpf .net core win7 独立运行补丁安装记录

wpf .net core win7 独立运行补丁安装记录

时间:2022-10-28 22:45:51浏览次数:60  
标签:core hModule KB2533623 补丁 win7 installed Kernel32 using wpf

 Windows 7 系统上,根据 dotnet 官方文档,需要安装上 KB2533623 补丁

方案如下:

首先使用 fx 2.0 写一个启动器 如果检测可以运行则拉起.net core 主程序 否则弹出命令行提示安装补丁

 

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里 补丁放在同一个目录

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  

标签:core,hModule,KB2533623,补丁,win7,installed,Kernel32,using,wpf
From: https://www.cnblogs.com/dongzhaosheng/p/16837731.html

相关文章

  • vs无法打开包括文件corecrt.h
    (39条消息)vs2017中报无法打开包括文件:corecrt.h:Nosuchfileordirectory,400+错误_默茉的博客-CSDN博客(39条消息)无法打开包括文件:“corecrt.h”:Nosuchfil......
  • 去除.net core 多语言目录
    1.产生原因由Microsoft.VisualStudio.Web.CodeGeneration.Design包导致2.解决方法 如果确实需要某种语言资源文件,可以这样,右键编辑项目文件,在<PropertyGroup>添加如下......
  • 解决 win7 注册com组件失败问题
    解决win7注册com组件失败问题运行:regsvr32xxx.ocx提示:模块"xxx.ocx"已加载,但对调用dllregisterserver的调用失败,错误代码0x80004005。问题分析:由于win7权限导......
  • python3.9不支持win7
    安装:Anaconda3-2022.10-Windows-x86_64.exe会报错:FailedtocreateAnacondamenus详细信息:ErrorloadingPythonDLLxxxpython39.dll,LoadLibrary:PyInstaller:Forma......
  • .NET Core WebApi 多语言本地化,动态切换多语言
    .NETCoreWebApi多语言本地化,动态切换多语言原生的.netcorewebapi动态多语言本地话具体更多详细内容,可以参考官方文档首先看效果图整体项目结构图......
  • Java — 程序设计基础(Core Java I)
    了解基本程序设计结构:这章节有几个以前没注意的坑,在这里贴出来~提醒以后的自己也希望过路的朋友踩。基本数据类型/运算符1.System.out.println(2.0-1.1)打出来的是0.89......
  • Java — 集合(1)(Core Java I)
    13.1集合接口本节将介绍Java结合框架的基本设计,展示使用他们的方法,并解释一些颇具争议的特性背后的考虑。13.1.1将集合的接口与实现分离队列接口指出可以在队列的尾部添加......
  • .Net Core通过GDI+在CentOS 7(Docker)环境中绘图报错The type initializer for 'Gdip'
    记一次.NetCore通过GDI+在CentOS7(Docker)环境中绘图报错Thetypeinitializerfor'Gdip'threwanexception的问题及处理方式  目录一、前言二、问题分析......
  • 如何用界面组件DevExpress WPF创建Excel式的过滤功能?赶紧Get
    DevExpressWPF拥有120+个控件和库,将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpressWPF能创建有着强大互动功能的XAML基础应用程序,这些应用程序专......
  • 【HMS Core】定位服务逆地理编码问题
    ​关于华为HMS-定位服务非华为手机逆地理编码不可用的问题。背景:在非华为手机例如小米手机上集成华为定位服务的逆地理编码功能运行后,报错HMSSDK_ServiceErrorCodeAdapto......