Comments (6)
Yeah, it seems that was the problem.
I can handle without WithAutoConcreteTypeResolution =)
Thanks man
from dryioc.
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.
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.
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.
Cool, anyway need to improve some things.
AutoConcreteTypeResolution
probably should not consider Func
arguments.
from dryioc.
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)
- Consistent behavior of a faulty singleton HOT 2
- FactoryType is not forwarded in the RegisterMapping<TService, TRegisteredService> method HOT 1
- IDisposable dependencies does not get disposed when web request ends HOT 5
- Add the HotUsedInstance for fast access to skip all the resolution steps
- Conditional registrations
- MS DI AddKeyed... variant registration fails HOT 8
- Check for mismatch lifestyle scope between service and dependencies HOT 7
- troubleshooting sudden ArgumentException at TryInterpretSingletonAndUnwrapContainerException HOT 3
- [question/feature request] keyed services in delegate resolution HOT 8
- Use default constructor if no registration is found
- Add the global test option to run all tests with WithoutUseInterpretation option
- Feature Request: add global .WithDefaultServiceTypeCondition(Func<Type, bool> condition) method HOT 1
- System.NullReferenceException: Object reference not set to an instance of an object HOT 5
- 'WithConcreteTypeDynamicRegistrations' results in unintended instantiation HOT 3
- Exception: Window already exists HOT 4
- Resolve enforces passed arguments to be used (and fails because of it) HOT 4
- Type registered with Singleton instantiating multiple times
- [BUG] Resolve<> crashes with the misleading, casting-related Exception when class is also registered using RegisterInitializer HOT 5
- Virus Warning with DryIoc Version 5.4.3 on Some Antivirus Software HOT 1
- Resolving func-wrapper when having circular-dependency throws RecursiveDependencyDetected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dryioc.