首页 新闻 会员 周边

vs2022生成项目失败

0
悬赏园豆:200 [已解决问题] 解决于 2024-06-20 15:22

web项目,之前都正常,生成时突然提示
未经处理的异常: System.IO.FileNotFoundException: 未能加载文件或程序集“System.Text.Encoding, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。系统找不到指定的文件。
framework版本是4.8的。

问题补充:

目前尝试修复了framework,还是一样的错误。

luytest的主页 luytest | 初学一级 | 园豆:24
提问于:2024-06-13 21:04
< >
分享
最佳答案
0

已解决。
我试过的方法有
1.清理 %temp% 目录下的临时文件。
删除 %windir%\Microsoft.NET\Framework[version]\Temporary ASP.NET Files 和 %windir%\Microsoft.NET\Framework64[version]\Temporary ASP.NET Files 下的内容。
清理Visual Studio的组件缓存,通常位于 %LocalAppData%\Microsoft\VisualStudio[Version]\ComponentModelCache。

2.用官方的framework工具修复。

3.更新nuget的引用,并删除所有已弃用的包。

然后编译通过,本地开发调试正常。

以上3种我是执行完毕后重启电脑开始编译项目的,因此并不能确定是哪一步起到了关键作用。

luytest | 初学一级 |园豆:24 | 2024-06-20 15:21
其他回答(2)
0

试试 stackoverflow 上 Could not load file or assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 回答中的解决方法:

  1. Update Visual Studio to the latest version (it matters)
  2. Remove all binding redirects from web.config
  3. Add this to the .csproj file:
<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
  1. Build the project
  2. In the bin folder there should be a (WebAppName).dll.config file
  3. It should have redirects in it, copy these to the web.config
  4. Remove the above snipped from the .csproj file
收获园豆:200
dudu | 园豆:31048 (高人七级) | 2024-06-15 09:24

试过了,没有解决这个问题,看来我只能重装系统。

支持(0) 反对(0) luytest | 园豆:24 (初学一级) | 2024-06-18 17:03
0

1、直接调试运行,看下哪个地方报的这个问题;

2、添加系统日志,确定问题所在,它这个说是没找到文件;

lzhdim | 园豆:650 (小虾三级) | 2024-06-15 18:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册