VS2022创建WPF App(.NET Framework)项目遇资源文件缺失等问题求助
环境信息
- Visual Studio 2022:初始版本17.0_50c4cab0,当前为Microsoft Visual Studio Professional 2022 (64位) 17.8.3
- .NET Framework 版本:4.8
问题现象
创建WPF App(.NET Framework)项目时,最初出现Access denied (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))错误,删除privateregistry.bin文件后该问题解决,但随即触发新错误:
- 提示:
The file Resources.resx could not be found within the project templates, continuing to run, but the resulting project may not build properly - 点击确定后弹出:
Error HRESULT E_FAIL has been returned from a call to a COM component
已尝试的无效操作
- 修复并重启Visual Studio
- 删除
%LocalAppData%\Microsoft\VisualStudio路径下的privateregistry.bin文件 - 多次重启VS
- 重置VS所有设置
- 以管理员身份运行VS
解决方案尝试
1. 清理用户模板缓存
删除以下路径下的所有文件及文件夹:
%USERPROFILE%\Documents\Visual Studio 2022\Templates\ProjectTemplates%USERPROFILE%\Documents\Visual Studio 2022\Templates\ItemTemplates
删除完成后重启VS,重新创建项目。
2. 重置VS配置并重新注册组件
以管理员身份打开命令提示符,执行以下命令:
cd "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE" devenv /resetuserdata devenv /setup
等待命令执行完毕后重启VS。
3. 修复模板文件
从一台正常运行同版本VS 2022的机器上,复制WPF App(.NET Framework)模板对应的Resources.resx文件,粘贴到本地模板路径(通常为C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\ProjectTemplates\CSharp\Windows\WPF),替换损坏或缺失的文件。
4. 彻底重装VS
若上述方法均无效,使用Visual Studio官方卸载工具(确保清理所有残留文件)卸载当前VS,然后重新下载安装17.8.3版本。
内容的提问来源于stack exchange,提问作者Viji Priya
相关产品推荐
相关产品推荐

