question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.Net Core Preview 5 Issue

See original GitHub issue

With the current .net core preview 5 i got an exception when building the automapper.

Exception

InvalidOperationException: No constructor for type ‘AutoMapper.Configuration.MapperConfigurationExpression+NamedProfile’ can be instantiated using services from the service container and default values.

Startup

            services.AddScoped(e => e.GetRequiredService<MapperConfiguration>().CreateMapper());

            services.AddSingleton(e => new MapperConfiguration(c =>
            {
                foreach (var profile in e.GetServices<Profile>())
                {
                    c.AddProfile(profile);
                }
            }));

I also tried to use your extension, which fails too.

Exception

InvalidOperationException: Unable to resolve service for type ‘System.IO.DirectoryInfo’ while attempting to activate ‘Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository’.

Startup

services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

Maybe this is not directly related to the automapper itself. But the question for me is, is there any plan to improve the wireup? Whouldn’t it be easier if the MapperConfiguration resolves the profiles at runtime itself via constructor injection?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lbargaoanucommented, May 12, 2019

As it has been discussed many times before, profiles are singletons and allowing DI for them would be easily abused. Other than that, AM itself doesn’t do DI, only the extension does. About the error itself, feel free to investigate.

0reactions
lock[bot]commented, Jul 3, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's new in .NET 8 Preview 5 [WIP] · Issue #8436
NET 8 Preview 5. This issue is for teams to highlight work for the community that will release in .NET 8 Preview 5....
Read more >
ASP.NET Core updates in .NET 8 Preview 5
NET 8 Preview 5 is now available and includes many great new improvements to ASP.NET Core. Here's a summary of what's new in...
Read more >
NET Core 5.0.0-preview.7
Release 5.0.0-preview.7 of .NET Core, released on 2020-07-21. versionsof.net gives an overview of all releases and versions of .NET Core.
Read more >
ASP.NET Core in .NET 8 Preview 5: Improved Debugging ...
NET 8 Preview 5 brings significant additions to ASP.NET Core. Notable enhancements include an improved debugging experience for ASP.NET Core ...
Read more >
5 Blazor Improvements in New .NET 8 Preview 5
NET Core web-dev component in the new .NET 8 Preview 5. Preview 5 basically marks the halfway point of the .NET 8 schedule,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found