Skip to content

Can't resolve some controller parameters if scanning in the registry #19

@mcliment

Description

@mcliment

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions