其他分享
首页 > 其他分享> > 【.NET core】Could not load file or assembly

【.NET core】Could not load file or assembly

作者:互联网

 NET core 添加了新的nuget包,部署出现Could not load file or assembly

这个坑,今天整了一天,我添加了Microsoft.AspNetCore.Mvc.Versioning包,结果发布到服务器,我复制了dll过去出现了一直找不到加载不成功的问题

 

Startup.ConfigureServices一直加载不成功,出错如下:

1 2 3 4 5 6 7 8 9 Application startup exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Versioning, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. 系统找不到指定的文件。 File name: 'Microsoft.AspNetCore.Mvc.Versioning, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at SC.API.Startup.ConfigureServices(IServiceCollection services) --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

后面仔细发现,添加了新的nuget包,发布后,在发布地址的目录下 找到这个文件

 

 

 

 

*.deps.json 此文件会新增nuget包的依赖关系,比较后发现

 

 

 

 

 

解决方法:除业务DLL以外,还需要复制此json文件覆盖,使得项目可以加载nuget包,不然netcore 无法映射加载新的包

标签:load,core,---,assembly,AspNetCore,Hosting,nuget,Microsoft,加载
来源: https://www.cnblogs.com/cdaniu/p/15488992.html