美文网首页
解决.Net Core 发布后Could not load fi

解决.Net Core 发布后Could not load fi

作者: Sunday_1024 | 来源:发表于2021-07-31 10:12 被阅读0次

说起来奇怪,.net core项目发布到服务器上运行好好的,后来添加一个新的类库,再更新服务器就报这个异常,如下:

System.IO.FileNotFoundException: Could not load file or assembly 'HtmlAgilityPack, Version=1.11.34.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a'. 系统找不到指定的文件。
File name: 'HtmlAgilityPack, Version=1.11.34.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a'

其实从字面意思上看,就是没找到这个类库的dll,但是我确实也发布到服务器上了的。以前的framework版本,都是在web.config有设置的,可在.net core中web.config 基本没什么东东。后来发现.net core不是在web.config里设置。

在发布文件里有个 xxxxxx.Web.deps.json 文件(xxxxxx为你项目名称),打开就能看到使用三方类库的配置,如下图


使用HtmlAgilityPack.dll

最终服务器更新 xxxxxx.Web.deps.json 解决此问题。

相关文章

网友评论

      本文标题:解决.Net Core 发布后Could not load fi

      本文链接:https://www.haomeiwen.com/subject/ipvhvltx.html