문제

I am investigating integrating N2CMS into an existing website.

The problem that I am getting is that the IOC engine that N2CMS uses (tinyIoC) doesnt know about any of the dependencies of my Controllers. So when any of my Controllers are created I get an error similar to :

TinyIoCResolutionException: Unable to resolve type: NLog.Logger (where NLogger is a dependency of a Controller that is being instantiated)

My website uses Ninject; I have worked out that N2CMS will use a Service Locator (an implementation of a N2.Engine.IServiceContainer) to push dependencies around.

Has anybody built anything similar ?

도움이 되었습니까?

해결책

I suspect you are using Dynamico? Out of the box, it resolves the controllers from the N2CMS container.

My first step in setting up an N2CMS project is to modify the controller factory to return the controller from my own container. N2 services are never injected into my controllers or business logic layer.

Use N2.Context to access everything you need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top