You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2022安装/修复失败 触发System.Numerics与Newtonsoft.Json异常

问题描述
  • 故障环境:Win10系统,已安装VS2022 Enterprise,此前已开启自动绑定重定向功能
  • 初始故障:运行.NET 4.7.2项目时触发System.Numerics库缺失或版本不匹配报错
  • 衍生故障:启动VS Installer时不展示任何已安装或可用组件,但VS2022本身可正常运行;尝试修复过程中故障加重,已尝试在线重装、安装程序自带修复、系统“添加或删除程序”卸载、installcleanup.exe手动卸载、重命名Installer文件夹、移除GAC内所有相关程序集等方案均无效
  • 安装程序弹窗报错:Unable to acquire update installer
  • 核心错误日志:
VisualStudio Bootstrapper:15/07/2022 14:09:48: Caught Exception: Type = TypeInitializationException,
    Message = The type initializer for 'Newtonsoft.Json.Utilities.ConvertUtils' threw an exception.,
    StackTrace =    at Newtonsoft.Json.Utilities.ConvertUtils.GetTypeCode(Type t, Boolean& isEnum)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.IsJsonPrimitiveType(Type t)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Microsoft.VisualStudio.Setup.Utility.JsonUtility.ParseNameValuePairJson(String jsonContents)
   at Microsoft.VisualStudio.Setup.Utility.JsonUtility.ParseNameValuePairJsonFile(IServiceProvider services, String filePath)
   at Microsoft.VisualStudio.Setup.Bootstrapper.Program.Parse(String[] args, IServiceProvider serviceProvider, IC2RSignatureReaderInterop c2rSignatureReader, String entryAssemblyProcessName, String entryAssemblyProcessFullName)
InnerException:Type = FileNotFoundException,
    Message = Could not load file or assembly 'System.Numerics, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.,
    StackTrace =    at Newtonsoft.Json.Utilities.ConvertUtils..cctor()
  • 已排除无效方案:常规控制面板卸载、点击安装程序修复按钮、重命名安装文件夹后使用内置报告问题功能、命令行离线安装均失败,无需提供此类方案。
  • 初步判断:异常导致安装程序无法解析temp/boostrapper.json文件,需要无需重装操作系统的解决方案。
解决方案

按优先级依次执行以下操作,每步完成后测试VS Installer是否恢复正常:

  1. 修复系统内置.NET Framework组件
    以管理员身份运行命令提示符,依次执行以下命令修复损坏的系统文件:
    sfc /scannow
    DISM /Online /Cleanup-Image /RestoreHealth
    
    命令执行完成后重启设备,检查C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Numerics路径下是否存在4.0.0.0版本对应程序集,若不存在,从相同版本Win10系统的对应路径拷贝System.Numerics.dll放回该目录即可,无需手动注册到GAC。
  2. 清理损坏的安装缓存与临时文件
    结束所有VS、VS Installer相关进程后,删除以下目录内的所有内容:
    • %ProgramData%\Microsoft\VisualStudio\Packages
    • %LocalAppData%\Microsoft\VisualStudio\Packages
    • %Temp%路径下所有包含bootstrapper、vsinstaller关键字的临时文件/文件夹
      完成后重新下载最新版VS2022 Enterprise引导程序,右键选择「以管理员身份运行」测试。
  3. 强制指定引导程序的程序集加载路径
    若上述操作无效,在下载的vs_enterprise.exe同级目录下新建vs_enterprise.exe.config文件,写入以下配置强制绑定系统内置的System.Numerics版本,绕开GAC加载异常问题:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Numerics" publicKeyToken="b77a5c561934e089" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            <codeBase version="4.0.0.0" href="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Numerics.dll" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    
    保存后再次以管理员身份运行引导程序。
  4. 修复系统程序集权限
    若仍报文件找不到错误,检查C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Numerics.dll的NTFS权限,确保LOCAL SERVICE、Administrators、SYSTEM账户均拥有读取和执行权限,权限异常时手动继承上级目录权限即可。

注意:执行以上操作前无需卸载现有VS2022实例,修复完成后原有VS配置、已安装组件均不会丢失。


内容的提问来源于stack exchange,提问作者evilmandarine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 19:27:29