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

升级VS至17.5.2后Kentico Xperience 13站点启动异常求助

问题描述

使用Kentico Xperience 13开发的基于.NET 6的网站已稳定运行一年以上,将Visual Studio升级至17.5.2(同时安装了.NET 7组件)后,重新构建生产站点,无论是IIS还是IIS Express均无法启动。Visual Studio无编译报错,但浏览器抛出以下异常:

NullReferenceException: Object reference not set to an instance of an object.
CMS.Membership.Internal.VirtualContextAuthenticationConfiguration.get_Audience()

DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor()' on type 'VirtualContextRequestPrincipalRetriever'.
Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()

DependencyResolutionException: An exception was thrown while activating λ:Kentico.Web.Mvc.Internal.IRequestPrincipalRetriever[] -> Kentico.Content.Web.Mvc.VirtualContextRequestPrincipalRetriever.
Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action next)

已尝试卸载.NET 7、重新安装Visual Studio,问题仍未解决。

解决方案
  • 校验Kentico包版本兼容性:确认所有Kentico相关NuGet包(如Kentico.Content.Web.Mvc、Kentico.Web.Mvc等)的版本与Kentico Xperience 13官方兼容版本一致,避免VS升级后依赖包意外更新导致的注入错误。
  • 锁定.NET SDK版本:在项目根目录创建global.json文件,强制指定使用.NET 6 SDK构建,防止VS默认调用.NET 7 SDK:
    {
      "sdk": {
        "version": "6.0.408",
        "rollForward": "latestMinor"
      }
    }
    
  • 清理项目缓存与依赖:
    1. 删除项目目录下的bin和obj文件夹
    2. 在Visual Studio的「工具」→「NuGet包管理器」→「包管理器设置」中,点击「清除所有NuGet缓存」
    3. 重新还原NuGet包并重新构建项目
  • 检查认证配置项:异常指向VirtualContextAuthenticationConfiguration.Audience为空,确认appsettings.json或Kentico配置中已正确设置虚拟上下文模式下的Audience参数,确保配置项存在且不为空。
  • 安装Kentico最新补丁:登录Kentico官方门户,下载并安装对应版本的累积更新,修复VS 2022升级后的兼容性问题。

内容的提问来源于stack exchange,提问作者Sylvain C.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 07:33:12