-
Notifications
You must be signed in to change notification settings - Fork 29
Description
When scanning for things in the registry, some types can't be resolved in the controller constructor (in the case of the example IOptions but I don't think it's exclusive to this type).
I have pushed some code to reproduce the issue:
https://github.com/mcliment/StructureMap.Microsoft.DependencyInjection/tree/issue-demo
To reproduce, run the sample site and go to /Bad. This should throw an exception because the type IOptions<MySettings> can't be resolved. Then go to /Good and should work, loading the same type through a wrapper. Then "/Bad" works perfectly.
The thing it that TryGetInstance can't resolve the type the first time (GetInstance works properly).
If the registry.Scan is removed from ConfigureContainer and the type MySettingsWrapper is added as services.AddTransient<IMySettingsWrapper, MySettingsWrapper>(); then /Bad works the first time.
As well, if the Scan has the clause a.Exclude(t -> true); instead of the Include(...) also works the first time.