jbogard / MediatR.Extensions.Microsoft.DependencyInjection

MediatR extensions for Microsoft.Extensions.DependencyInjection
MIT License
327 stars 89 forks source link

Error When Using Microsoft.AspNetCore.TestHost #39

Closed mikelunn closed 5 years ago

mikelunn commented 5 years ago

When my test project spins up TestServer and hits services.AddMediatR(typeof(Startup)) the following error is thrown: System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'

The issue seems similiar to this Automapper DI Extensions issue

Versions: Mediatr: 5.0.1 MediatR.Extensions.Microsoft.DependencyInjection: 5.0.2 AspNetCore: 2.0.8

Test Project Microsoft.AspNetCore.TestHost: 2.1.1 xunit.runner.visualstudio: 2.3.1 Microsoft.NET.Test.Sdk: 15.7.0

jbogard commented 5 years ago

What do the LoaderExceptions show?

mikelunn commented 5 years ago

SMH. Was thrown off by this error. I had to catch ReflectionTypeLoadException to be able to see the actual LoaderExceptions, which unveiled unable to reference EntityFrameworkCore. Closing this issue. And thanks for all the great work you do!