ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
337 stars 33 forks source link

Error with Aspnet Core 2.0 #111

Closed tiagorosendo closed 7 years ago

tiagorosendo commented 7 years ago

When i run one API with aspnet core 2.0 and grace i have this error message:

Grace.DependencyInjection.Exceptions.LocateException: 'Could not locate Type System.Func3[System.String,Microsoft.Extensions.Logging.LogLevel,System.Boolean] 1 Importing Microsoft.Extensions.Logging.ILoggerProvider 2 Importing System.Func3[System.String,Microsoft.Extensions.Logging.LogLevel,System.Boolean] for constructor parameter filter '

ipjohnson commented 7 years ago

@tiagorosendo it looks like the constructor for the logging implementation was changed in ASP.Net core to have multiple constructors and Grace as well as other containers are having issues as the longest constructor is being used ...

I'll take a look this weekend about updating the best matching constructor logic to unroll Func<T,TResult> a little better so it picks the correct constructor in this case.

For the moment you can probably cheat and register a Func<string,LogLevel,bool> with the container just to get you down the road till I can fix it this weekend.

Sorry about this I had tested with the DI suite test that MS provides but this behavior isn't specified in the new tests.

ipjohnson commented 7 years ago

@tiagorosendo I've tested my changes in a test asp.net core 2.0 app everything looks good so I'm going to close this out and release a nuget package with it.