Unity - Resolution of the dependency failed (without registering)

前提是你 提交于 2019-12-05 18:50:35

If they said that about Unity, they're wrong. Unity will resolve a concrete type (.Resolve<MyClass>), but interfaces have to be explicitly registered by associating them with concrete types.

There are extensions such as Unity Auto Registration to provide those features; I have no experience with them.

I'm not aware of that feature in Unity. As far as I know, it will happily resolve unregistered concrete types, but has to have had a concrete type registered for any abstract types or interfaces. Best bet is to register it:

ServerUtility.Container.RegisterType<IMaterialClient, ConcreteMaterialClient>();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!