Can't resolve a registered class?
Issue #6
resolved
Okay, one of two things is going on here: either there is a bug somewhere or I don't know what the hell I'm doing. I'm happy with either outcome, and would prefer the latter.
Please unzip the following project, compile, run, and press the button. I get:
Debugger Exception Notification
Project Project49.exe raised exception class EResolveException with message 'Cannot resolve the dependency: TAnotherClass.'.
Break Continue Help
I'm more than happy to be shown what I'm doing wrong.....
Comments (3)
-
repo owner -
reporter Hey, thanks very much, Stefan. Makes sense -- I should have seen that.
Nick
-
repo owner - changed status to resolved
fixed issue
#6(class gets registered as service type if no other service was already registered for that class)→ <<cset 543c954433ac>>
- Log in to comment
You did not tell the container anywhere that you want to use the class itself as a service. It only does that in the resolve method by itself (which I consider kind of a hack so far - see the comment in the code there).
If you just write RegisterType<TSomeClass> you actually did not specify any service.
I am not sure if when calling Build (which you did not and which would lead to an exception later) there should be an exception that you did not specify any service type or that it should automatically register the class type as service type (as it does in the resolve method now).
I am open for suggestions.
To get around the bug for now you just have to write RegisterType<TAnotherClass, TAnotherClass> or RegisterType<TAnotherClass>.Implements<TAnotherClass>