Skip to content

Disposing a container with no extensions causes a NullReferenceException #74

@FodderMK

Description

@FodderMK

The following code causes a NullReferenceException:

var injector = new InjectionContainer();
injector.Dispose();

This is caused by the foreach loop in InjectionContainer.cs line 146 trying to loop through a list that hasn't been initialized. This can be fixed either checking for a null list before looping or changing line 26 to read:

private List<IContainerExtension> extensions = new List<IContainerExtension>();

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions