<PackageReference Include="Castle.Windsor" Version="5.0.0" />

ComponentNotFoundException

Exception threw when a request for a component cannot be satisfied because the component does not exist in the container
using System; namespace Castle.MicroKernel { [Serializable] public class ComponentNotFoundException : ComponentResolutionException { public string Name { get; set; } public Type Service { get; set; } public ComponentNotFoundException(string name, Type service, int countOfHandlersForTheService) : base(BuildMessage(name, service, countOfHandlersForTheService)) { Name = name; Service = service; } public ComponentNotFoundException(string name, string message) : base(message) { Name = name; } public ComponentNotFoundException(Type service, string message) : base(message) { Service = service; } public ComponentNotFoundException(Type service) : this(service, $"""{service.FullName}""") { } private static string BuildMessage(string name, Type service, int countOfHandlersForTheService) { string text = $"""{name}""{Environment.NewLine}"; if (countOfHandlersForTheService == 0) return text + $"""{service.FullName}"""; if (countOfHandlersForTheService == 1) return text + $"""{service.FullName}"""; if (countOfHandlersForTheService > 1) return text + $"""{countOfHandlersForTheService}""{service.FullName}"""; return text; } } }