简体   繁体   English

从 .net 核心 2.2 到 3.0 的转换失败

[英]Failed conversion from .net core 2.2 to 3.0

Last week I upgraded my .NET Core Web API from 2.2 to 3.0.上周我将我的 .NET Core Web API 从 2.2 升级到 3.0。

I had a lot of issues with packages and still struggling.我在包裹方面遇到了很多问题,但仍在苦苦挣扎。

Case 1: What I have right now is that all of my tests are failing: unit tests, integrations tests, etc.案例 1:我现在的所有测试都失败了:单元测试、集成测试等。

I'm using:我在用着:

  • Nunit (3.12.0) Nunit (3.12.0)
  • NUnit3TestAdapter (3.15.1) NUnit3TestAdapter (3.15.1)
  • Moq 4.13.0起订量 4.13.0
  • Microsoft.NET.Test.sdk (16.2.0) Microsoft.NET.Test.sdk (16.2.0)
  • Microsoft.AspNetCore.Mvc.Testing Microsoft.AspNetCore.Mvc.Testing

When I start debugging my tests I get the following error message:当我开始调试我的测试时,我收到以下错误消息:

System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'Microsoft.IntelliTrace.Core, Culture=neutral, PublicKeyToken=null'. System.IO.FileNotFoundException HResult=0x80070002 消息=无法加载文件或程序集“Microsoft.IntelliTrace.Core,Culture=neutral,PublicKeyToken=null”。 The system cannot find the file specified.该系统找不到指定的文件。 Source=System.Private.CoreLib.源 = System.Private.CoreLib。

The error occurred in the RuntimeAssembly file (part of system.private.corelib), method InternalLoadAssemblyName .错误发生在RuntimeAssembly文件(system.private.corelib 的一部分)的方法InternalLoadAssemblyName中。

When I continue I get this:当我继续我得到这个:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. System.Reflection.ReflectionTypeLoadException: '无法加载一种或多种请求的类型。 Could not load file or assembly 'Microsoft.IntelliTrace.Core, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.无法加载文件或程序集“Microsoft.IntelliTrace.Core,版本=16.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a”。 The system cannot find the file specified.'该系统找不到指定的文件。'

Case 2: When I'm not debugging my tests but just run my application en startup swagger, I can use every call but my output window is filled with thousands of Exceptions like thrown:案例 2:当我不调试我的测试而只是在启动 swagger 时运行我的应用程序时,我可以使用每个调用,但我的 output window 充满了成千上万的异常:

'System.InvalidCastException' in Swashbuckle.AspNetCore.SwaggerGen.dll Swashbuckle.AspNetCore.SwaggerGen.dll 中的“System.InvalidCastException”

This happens when the Linq class Where.SpeedOpt.cs is used and the List.cs class of generic, also in System.Private.CoreLib .当使用 Linq class Where.SpeedOpt.csList.cs class 通用的,也在System.Private.CoreLib中时,会发生这种情况。

Are case 1 and case 2 related to each other?案例 1 和案例 2 是否相互关联?

Anyone have a workaround or solution?有人有解决方法或解决方案吗?

Case 1 also fixed:案例 1 也修复了:

When using.Net Core 3.0 and automapper you should add automapper with additional parameter使用 .Net Core 3.0 和 automapper 时,您应该添加带有附加参数的 automapper

services.AddAutoMapper(typeof(Startup)); services.AddAutoMapper(typeof(Startup));

In.Net core 2.2 i just had我刚刚拥有的 In.Net core 2.2

services.AddAutoMapper(); services.AddAutoMapper();

He fails on this during unit and integrationtesting not on normal startup他在单元和集成测试期间没有在正常启动时失败

Case 2 (swagger error) is solved.案例2(招摇错误)已解决。 Seems there was a bug in the swagger 5.0.0 packages That bug is solved in the 5.0.0-rc4 version似乎 swagger 5.0.0 包中存在错误该错误已在 5.0.0-rc4 版本中解决

Case 1 is still open.案例 1 仍然开放。 I tried to reproduce with different coding and see what the results are.我试图用不同的编码重现,看看结果是什么。

When i instantiate a new httpclient, there is no error.当我实例化一个新的 httpclient 时,没有错误。 Nevertheless, i can not call my api because it's secured and i get the "unathorized" error (normal behaviour)不过,我不能打电话给我的 api 因为它是安全的,我得到“未经授权的”错误(正常行为)

When i instantiate a new httpclient with my webapplicationfactory, there is the error.当我用我的 webapplicationfactory 实例化一个新的 httpclient 时,出现了错误。 Is there something that is not initialized from startup when i run my tests instead of running the core api thru normal startup and calling swagger?当我运行我的测试而不是通过正常启动运行核心 api 并调用 swagger 时,是否存在未从启动初始化的内容? Maybe a problem in startup that is only an issue in unit and integrationtests?也许启动中的问题只是单元和集成测试中的问题?

Regards问候

GSharp夏普

I'm not sure whether it is your case or not.我不确定这是不是你的情况。 Having a similar issue I found this topic https://developercommunity.visualstudio.com/content/problem/738856/could-not-load-file-or-assembly-microsoftintellitr.html which led me to https://github.com/microsoft/vstest/pull/2226 . Having a similar issue I found this topic https://developercommunity.visualstudio.com/content/problem/738856/could-not-load-file-or-assembly-microsoftintellitr.html which led me to https://github.com /microsoft/vstest/pull/2226

it looks like they have a bug.看起来他们有一个错误。 But I still not sure how to fix it in my case但我仍然不确定如何在我的情况下解决它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM