Skip to content

Avoid AsyncScopedLifeStyle in ServiceCollection Integration as Default #24

@sephit

Description

@sephit

In SimpleInjectorServiceCollectionExtensions

Hi

I've been trying to use ServiceCollection Integration on a Win Form Project which is defined as Transient in the DefaultLifestyle but i have a problem whenever I use the ServiceCollection Integration, exactly in the AddSimpleInjector method which try change the DefaultScopedLifeStlye (which is null in the first place).

// Set lifestyle before calling setupAction. Code in the delegate might depend on that.
TrySetDefaultScopedLifestyle(container);
private static void TrySetDefaultScopedLifestyle(Container container)
{
    if (container.Options.DefaultScopedLifestyle is null)
    {
        container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
    }
}

It throws an exception related that the DefaultScopedLifestyle shouldn't be changed after initialization..

Is this the expected behavior?

Why should it changed to a AsyncScopedLifeStyle if i am working with a Transient lifestyle?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions