Could not load type 'Context' from assembly 'Microsoft.AspNetCore.Hosting, Version=3.0.0.0

被刻印的时光 ゝ 提交于 2020-12-30 05:49:51

问题


Where using .netcore 2.2 an upgrade to .netcore 3.0

This is the error that we encounter when running unit test:

"Could not load type 'Context' from assembly 'Microsoft.AspNetCore.Hosting, Version=3.0.0.0"


回答1:


These steps work on our project:

  1. Remove old packages
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
  1. Install
    Microsoft.AspNetCore.Mvc.Testing 3.0.0-preview7.19365.7
  1. Update Startup.cs
    .AddApplicationPart(Assembly.Load("YourProjectControllerNamespace"))



来源:https://stackoverflow.com/questions/57302131/could-not-load-type-context-from-assembly-microsoft-aspnetcore-hosting-versi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!