Visual Studio 2022启动失败(LoadPackageWithContext未授权异常)求助
- 启动Visual Studio 2022时,短暂显示欢迎窗口(可选择固定或最近解决方案)后陷入白屏冻结,随即闪退。
- 已尝试将版本从17.3.5更新至最新17.5.4、重启电脑,均无效。
安全模式启动VS排查
执行以下命令:
cd "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\" devenv /SafeMode /Log "%USERPROFILE%\VSSafeModeLog.xml"
弹出错误提示:
An exception was encountered while constructing the content of this frame.
This information is also logged in "C:\Users\MyUserName\VSSafeModeLog.xml".Exception details:
System.UnauthorizedAccessException: Access denied (Exception by HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage()
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.g__ConstructContentFromPackage|145_1(WindowFrame frame)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()
日志关键条目分析
日志文件实际为AppData\Roaming\Microsoft\VisualStudio路径下的ActivityLog.xml,其中关键条目如下:
许可证验证失败警告
<entry> <record>920</record> <time>2023/04/24 09:58:34.413</time> <type>Warning</type> <source>VisualStudio</source> <description>License validation task failed unexpectedly. The application will be shutdown.</description> </entry>
SVsToastService不可用错误
<entry> <record>914</record> <time>2023/04/24 09:58:34.064</time> <type>Error</type> <source>VS/LicensingNotifications/InitializeNotifications</source> <description>Microsoft.VisualStudio.Shell.ServiceUnavailableException: The SVsToastService service is unavailable.&#x000D;&#x000A; at Microsoft.VisualStudio.CommonIDE.LicensingNotifications.LicensingNotificationsProvider.&lt;InitializeNotificationsAsync&gt;d__20.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A; at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A; at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A; at Microsoft.VisualStudio.CommonIDE.LicensingNotifications.LicensingNotificationsProvider.&lt;&lt;InitializeNotifications&gt;b__19_0&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A; at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A; at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A; at Microsoft.VisualStudio.Shell.VsTaskLibraryHelper.&lt;&gt;c__DisplayClass35_0.&lt;&lt;FileAndForget&gt;b__0&gt;d.MoveNext()</description> </entry>
未转义的堆栈跟踪:
Microsoft.VisualStudio.Shell.ServiceUnavailableException: The SVsToastService service is unavailable. at Microsoft.VisualStudio.CommonIDE.LicensingNotifications.LicensingNotificationsProvider.<InitializeNotificationsAsync>d__20.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.CommonIDE.LicensingNotifications.LicensingNotificationsProvider.<<InitializeNotifications>b__19_0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Shell.VsTaskLibraryHelper.<>c__DisplayClass35_0.<<FileAndForget>b__0>d.MoveNext()
- 使用Microsoft 365在线授权的Visual Studio 2022 Professional,同事同款授权可正常运行。
- 其他Microsoft 365服务(如OneDrive)登录及使用无异常。
- 更新Visual Studio至最新版本
- 重启电脑
- 执行
sfc /scannow命令 - 搜索相关许可证/堆栈跟踪帖子,未找到有效解决方法
在重置整个VS环境前,还有其他解决方法吗?
内容的提问来源于stack exchange,提问作者LWChris

