diff --git a/src/Nethermind/Nethermind.Core/Container/ContainerBuilderExtensions.cs b/src/Nethermind/Nethermind.Core/Container/ContainerBuilderExtensions.cs index 24d739687c5..775350a187f 100644 --- a/src/Nethermind/Nethermind.Core/Container/ContainerBuilderExtensions.cs +++ b/src/Nethermind/Nethermind.Core/Container/ContainerBuilderExtensions.cs @@ -37,11 +37,16 @@ public static ContainerBuilder AddPropertiesFrom(this ContainerBuilder config ComponentKeyAttribute? componentKeyAttribute = propertyInfo.GetCustomAttribute(); if (componentKeyAttribute != null) { - configuration.RegisterInstance(val).Keyed(componentKeyAttribute.Key, propertyInfo.PropertyType); + configuration + .RegisterInstance(val) + .Keyed(componentKeyAttribute.Key, propertyInfo.PropertyType) + .ExternallyOwned(); } else { - configuration.RegisterInstance(val).As(propertyInfo.PropertyType); + configuration.RegisterInstance(val) + .As(propertyInfo.PropertyType) + .ExternallyOwned(); } } } @@ -63,7 +68,8 @@ public static ContainerBuilder AddInstance(this ContainerBuilder builder, T i { builder.RegisterInstance(instance) .As() - .SingleInstance(); + .SingleInstance() + .ExternallyOwned(); return builder; } @@ -132,7 +138,8 @@ public static ContainerBuilder RegisterNamedComponentInItsOwnLifetime(this Co public static ContainerBuilder Bind(this ContainerBuilder builder) where TImpl : notnull where TAs : notnull { builder.Register(ctx => ctx.Resolve()) - .As(); + .As() + .ExternallyOwned(); return builder; }