WCSF doesn't call Configure method in ModuleInitializer

Topics: Web Client Software Factory, User Forum
Aug 20, 2008 at 6:06 PM
Edited Aug 20, 2008 at 6:08 PM
I've created Foundation Module with Linq schema for my database access needs.
Also I've implemented Configure method like this:

        public override void Configure(IServiceCollection services, System.Configuration.Configuration moduleConfiguration)
            IDataCatalogService dataCatalogService = services.Get<IDataCatalogService>();
            string connection = moduleConfiguration.ConnectionStrings.ConnectionStrings[constConnectionStringProperty].ToString();

In debugger I found that this method never called for my module but it works well  for Shell module.
Whats wrong?
Aug 22, 2008 at 3:38 PM
Did you register your foundation module in configuration file?

Aug 22, 2008 at 4:13 PM
Edited Aug 22, 2008 at 4:15 PM
Yes of course.
in module section

      <module name="DataCatalog" assemblyName="DataCatalog">
          <dependency module="Shell" />

Aug 22, 2008 at 10:36 PM
Edited Aug 22, 2008 at 11:02 PM
Try this

      <module name="DataCatalog" assemblyName="DataCatalog" virtualPath="~/DataCatalog/Config">
          <dependency module="Shell" />

Put your configuration in web.config in the directory of DataCatalog/Config


Aug 23, 2008 at 7:51 AM
Thank you for explanation. :)
I will try today.
Aug 27, 2008 at 8:50 AM
Virtual path has been added to the web.config for DataCatalog foundation module. Module loads, service added to the Global Service list. But, when loads service that has DataCatalog as service dependency, WCFS reports "Service DataCatalog.Services.IDataCatalogService is not available in the current context.". When I remove virtualPath attribute from web config - everything is Ok but I have problem I reported in first post :)
Aug 27, 2008 at 3:52 PM
Edited Aug 27, 2008 at 5:58 PM
When you register DataCatalog service, you have to explicitly declare it as a global service. If not, the DataCatalog service should be in the module container, not in the root container. In the Config method, the services of root container is provided. So it has no DataCatalogService existing.
Aug 27, 2008 at 4:20 PM
Where I am wrong?

        public override void Load(CompositionContainer container)

        protected virtual void AddGlobalServices(IServiceCollection globalServices)
            globalServices.AddNew<DataCatalogService, IDataCatalogService>();
Aug 27, 2008 at 5:58 PM
Edited Aug 27, 2008 at 6:03 PM
I think when you add a virtualPath, in

public override void Load(CompositionContainer container), the container is module container, not root container. If there is no virtualPath, the container is root container.


Should be AddGlobalServices(container.Parent.Services);

Please refer your shell module's Load method.

Hope it helps

Aug 27, 2008 at 6:09 PM
it works, thank you :)
Aug 27, 2008 at 6:14 PM
You are welcome.