Failed conversion from .net core 2.2 to 3.0

2

Last week I upgraded my .NET Core Web API from 2.2 to 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.

I'm using:

  • Nunit (3.12.0)
  • NUnit3TestAdapter (3.15.1)
  • Moq 4.13.0
  • Microsoft.NET.Test.sdk (16.2.0)
  • 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'. The system cannot find the file specified. Source=System.Private.CoreLib.

The error occurred in the RuntimeAssembly file (part of system.private.corelib), method InternalLoadAssemblyName.

When I continue I get this:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Could not load file or assembly 'Microsoft.IntelliTrace.Core, Version=16.0.0.0, Culture=neutral, 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:

'System.InvalidCastException' in Swashbuckle.AspNetCore.SwaggerGen.dll

This happens when the Linq class Where.SpeedOpt.cs is used and the List.cs class of generic, also in System.Private.CoreLib.

Are case 1 and case 2 related to each other?

Anyone have a workaround or solution?

c#
.net
asked on Stack Overflow Oct 22, 2019 by GSharp • edited Oct 22, 2019 by Dale K

2 Answers

4

Case 1 also fixed:

When using .Net Core 3.0 and automapper you should add automapper with additional parameter

services.AddAutoMapper(typeof(Startup));

In .Net core 2.2 i just had

services.AddAutoMapper();

He fails on this during unit and integrationtesting not on normal startup

answered on Stack Overflow Oct 25, 2019 by GSharp
1

Case 2 (swagger error) is solved. Seems there was a bug in the swagger 5.0.0 packages That bug is solved in the 5.0.0-rc4 version

Case 1 is still open. I tried to reproduce with different coding and see what the results are.

When i instantiate a new httpclient, there is no error. Nevertheless, i can not call my api because it's secured and i get the "unathorized" error (normal behaviour)

When i instantiate a new httpclient with my webapplicationfactory, there is the error. 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? Maybe a problem in startup that is only an issue in unit and integrationtests?

Regards

GSharp

answered on Stack Overflow Oct 24, 2019 by GSharp • edited Oct 25, 2019 by GSharp

User contributions licensed under CC BY-SA 3.0