-
Notifications
You must be signed in to change notification settings - Fork 0
Exceptions
Table of Contents
The base exception class from which every other custom exception inherits.
Thrown when an implementation for an interface has not been found.
Also thrown when versioning and a valid version is not found.
solution: implement the interface.
Thrown when a type for a service has not been found.
The class or interface you wanted as served is not in a registered assembly.
Probably caused when you're using multiple projects.
solution: modify the settings to register the assembly of the service you want.
var settings = StackWrapperSettings.Default
.RegisterAssemblyOf<MyService>();
Injector.From<Something>(settings); // ...
Thrown when the specified class is NOT marked with [Service]
attribute
cause:
class MyService {}
solution:
[Service] // add the attribute
class MyService {}
note: you could also disable strict checks in settings, but it's not suggested.
Thrown when a class has no parameterless constructor to call.
cause:
[service]
class MyService
{
public MyService (int par)
{
// stuff
}
}
solution:
[service]
class MyService
{
public MyService () {} // add default constructor
public MyService (int par) // you could've also removed this.
{
// stuff
}
}
Thrown when the specified type has a field/property without a setter
cause:
[service]
class MyService
{
[Served]
MyOtherService service {get;}
}
solution:
[service]
class MyService
{
[Served]
MyOtherService service {get; set;}
}
note: you can add a setter to readonly
properties and injection will still work.
Thrown when the entry point is invalid.
causes:
// SOLUTION: AlwaysCreate is not a valid pattern for an entry point
[Service(Pattern = InstantiationPattern.AlwaysCreate)]
private class InvalidEntryTypeThrower { }
- trying to get an entry of a non-injected StackWrapper.