Giter Site home page Giter Site logo

Comments (6)

jkvargas avatar jkvargas commented on May 12, 2024 1

Yeah, it seems that was the problem.
I can handle without WithAutoConcreteTypeResolution =)
Thanks man

from dryioc.

dadhi avatar dadhi commented on May 12, 2024

Func<String, Microsoft.Extensions.Logging.LogLevel, Boolean>

The func returns bool, so it should be registered.

How and what does it mean is up to you.
You may register a method returning bool (via Made.Of) and use service key to identify it.

from dryioc.

jkvargas avatar jkvargas commented on May 12, 2024

dadhi, I believe I still need your help. I am running a asp.net core app. I tryed to follow examples around the internet but I am stuck.

Btw, I created a bare netcore 2.1 project if you have a moment to take a look.
https://github.com/jkvargas/samplemvcdryioc

I did try to minimize the code of my app, I just created a new mvc app with individual authentication using netcoreapp2.0. And I've tryed to integrate DryIoc.

`public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var container = new Container(rules => rules
                .WithoutThrowOnRegisteringDisposableTransient()
                .WithTrackingDisposableTransients()
                .WithAutoConcreteTypeResolution());

            container.Register<IAppConfig, AppConfig>(Reuse.Transient);

            var newContainer = container.WithDependencyInjectionAdapter(services, throwIfUnresolved: type => type.Name.EndsWith("Controller"));

            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            services.AddMvc();

            return newContainer.Resolve<IServiceProvider>();
        }`

It keeps returning "DryIoc.ContainerException: 'Unable to get constructor of Boolean using provided constructor selector when resolving Boolean {ReturnDefault} #101 with args [_String0]
in wrapper Func<String, Microsoft.Extensions.Logging.LogLevel, Boolean> {ReturnDefault} as parameter "filter" #11 with args [_String0]
in singleton Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider: Microsoft.Extensions.Logging.ILoggerProvider {ServiceKey=DefaultKey(0), ReturnDefault} #51
in wrapper IEnumerable<Microsoft.Extensions.Logging.ILoggerProvider> {ReturnDefault} as parameter "providers" #1
in singleton Microsoft.Extensions.Logging.LoggerFactory: Microsoft.Extensions.Logging.ILoggerFactory as parameter "factory" #41
in singleton Microsoft.Extensions.Logging.Logger<Microsoft.AspNetCore.Hosting.Internal.WebHost>: Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Hosting.Internal.WebHost> #100
from container.'"

Isn't this a problem with the integration?

from dryioc.

dadhi avatar dadhi commented on May 12, 2024

Now looking at used setup and exception I have more clues, thanks.

What if you remove WithAutoConcreteTypeResolution() ?

Any reason you need it?

Looking at your example, I have an idea how to improve exception messsge when using Auto resolution.

When I have time, I will check more thoroughly.

from dryioc.

dadhi avatar dadhi commented on May 12, 2024

Cool, anyway need to improve some things.

AutoConcreteTypeResolution probably should not consider Func arguments.

from dryioc.

dadhi avatar dadhi commented on May 12, 2024

After some thoughts, the automatic resolution should not consider a primitive type, like int, but using a Func<MyType> actually is fine.

from dryioc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.