Last post Sep 30, 2019 09:07 AM by Abraham Qian
Sep 26, 2019 08:00 AM|varoulscuprens|LINK
I am investigating a web project and I have encountered a class library. Its name is "UnitName.SampleProject.WcfIISHost" and it only has two files, one is "CategoryService.svc" and "NinjectFileLessServiceHostFactory.cs". And weirdly, "CategoryService.svc"
has only one row, as such:
<%@ ServiceHost Language="C#" Debug="true" Service="UnitName.SampleProject.BusinessLayer.Concrete.ProductManagement.CategoryService" Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" %>
and content of "NinjectFileLessServiceHostFactory.cs". is:
public class NinjectFileLessServiceHostFactory : NinjectServiceHostFactory
var kernel = new StandardKernel(new BusinessModule());
There are a Wcf library and Wcf Console host libraries out there and I understand them. What could the purpose of this library?
Thanks in advance.
Sep 30, 2019 09:07 AM|Abraham Qian|LINK
In short, due to changes in the hosting environment, IIS hosted WCF is different from console hosted WCF, in the console, we can add additional logic, add additional services, and endpoint behavior before the service is started through ServiceHost event,
or initialize the database and so on.
Because IIS does not instantiate Service host, events linked to the service lifecycle are all implemented through the Factory property.
Here is a detailed explanation.
NinjectServiceHostFactory extension adds support for Dedenpency injection for WCF service and behaviors.
Feel free to let me know If there is anything I can help with.