Select version
v7.18 v7.16 v7.13 v7.12 v7.11 v7.9 v7.8 v7.7 v7.6 v7.5 v7.3 v7.1 v7.0 v6.8 v6.7 v6.6 v6 v5 v4 v3 v2

Migrating Commerce element to Version 7.18

In Ucommerce version 7.18 the Commerce element and CommerceConfigurationSection in web.config no longer exists. We have moved this to being configuration done in our IoC container instead. It's the ideology that we want to move as much out of web.config as possible going forward, removing the commerce element being one of them. It also aligns perfectly with the idea of having as much configuration inside our IoC container as possible.

If you have made any custom configuration to your commerce element in web.config, you need to port this to IoC. You might also have to recompile your code as there is breaking changes. In this article we'll elaborate the breaking changes and how you fix them going forward.

Changes to web.config

Previously when installing Ucommerce we would insert the two following xml pieces. Theese are no long present should your Source control tell you they are removed, don't be scared. Its intentional :-)

    
    
      <commerce>
        <runtimeConfiguration enableCache="true"
          cacheProvider="NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=6876f2ea66c9f443"
          connectionString="(auto)"/>
        <catalogConfiguration defaultCultureCode="en-US" enforceCategoryNameUniquenessWithinCatalogs="true"/>
        <securityConfiguration enable="true"/>
      </commerce>
    
    
    
    
        <sectionGroup name="commerce" type="System.Configuration.ConfigurationSectionGroup">
          <section name="catalogConfiguration" type="UCommerce.Infrastructure.Configuration.CatalogConfigurationSection, UCommerce.Infrastructure"/>
          <section name="runtimeConfiguration" type="UCommerce.Infrastructure.Configuration.RuntimeConfigurationSection, UCommerce.Infrastructure"/>
          <section name="securityConfiguration" type="UCommerce.Infrastructure.Configuration.SecurityConfigurationSection, UCommerce.Infrastructure"/>
        </sectionGroup>
    
    

Breaking changes

  • UCommerce.EntitiesV2.SessionProvider constructor has changed arguments.
  • Removed Type UCommerce.Infrastructure.Configuration.CommerceConfigurationProvider.
  • Removed Type UCommerce.Infrastructure.Configuration.CatalogConfigurationSection.
  • Removed Type UCommerce.Infrastructure.Configuration.CommerceConfigurationSection.
  • Removed Type UCommerce.Infrastructure.Configuration.ShippingMethodServiceElement
  • Removed Type UCommerce.Infrastructure.Configuration.ExternalPaymentConfigurationSection.
  • Removed Type UCommerce.Infrastructure.Configuration.SecurityConfigurationSection.
  • Removed Type UCommerce.Infrastructure.Configuration.RuntimeConfigurationSection.

Porting from the old configuration

    
    
      <commerce>
        <runtimeConfiguration enableCache="true"
          cacheProvider="NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=6876f2ea66c9f443"
          connectionString="(auto)"/>
        <catalogConfiguration defaultCultureCode="en-US" enforceCategoryNameUniquenessWithinCatalogs="true"/>
        <securityConfiguration enable="true"/>
      </commerce>
    
    

The xml code above is an example of the commerce element formerly located in web.config. Any changes made to theese should be moved to IoC properties that are injected whereever needed.

In the future you override configuration with castle windsor properties. They are properties like any other component property, but globally defined and thus globally changed.

An example of the properties are defined in settings.config and looks like this:

    
    
    <configuration>
      
      <properties>
        <!-- Set database isolation level for NHibernate connections-->
        <databaseConnectionIsolationLevel>ReadUncommitted</databaseConnectionIsolationLevel>
    
        <!-- Security foundation can be disabled if set to false-->
        <securityFoundationEnabled>True</securityFoundationEnabled>
    
        <!-- 
          Overriding this connection string will force NHibernate to use this
          Connectionstring element in web.config named Ucommerce will superseed this configuration
        -->
        <connectionString>(auto)</connectionString>
    
        <!--Cache configuration for NHibernate-->
        <enableCache>True</enableCache>
    
        <!-- Cache provider used for NHibernate. Can be swaped out to a distributed cache or anything else-->
        <cacheProvider>NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=6876f2ea66c9f443</cacheProvider>
    
        <!-- If nothing else is found, default to this culture code for multi lingual data-->
        <defaultCultureCode>en-US</defaultCultureCode>
    
        <!-- If set to true, multiple categories with the same name within a catalog is not possible-->
        <enforceCategoryNameUniquenessWithinCatalogs>True</enforceCategoryNameUniquenessWithinCatalogs>
      </properties>
    
      <components>
    	...
      </components>
    </configuration>
    
    

Notice that the properties element sits outside the components element. This needs to be done like that in your app configuration file as well.

If you wish to override any of the properties e.g the connectionstring defined above, simply create a new config file, put it in app, and follow the pattern like this:

    
    
    <configuration>
      
      <properties>
        <connectionString>foo-connectionstring</connectionString>
      </properties>
    </configuration>
    
    

Support for hardcoded components.config path

When fireing up the IoC container we are searching for a file called components.config. It's convenient to scan for it, as things will automaically work. However in some cases it would be needed to specify it directly. This was previously supported on the commerce element that are now removed. Instead this feature has moved to AppSettings. If you wish to configure where the components.config file is located you can do so like this:

    
    
    	<appSettings>
    		<add key="UCommerceComponentsConfig" value="/somewhere/your/configuration/is/placed/components.config" />
    	</appSettings>
    
    

Support for hardcoded base directory path

In some cases using the default AppDomain base path is incompatible with the hosted solution. In that case, you can configure where the appdomain base directory path exists. You can use the following configuration property for this.

    
    
    	<appSettings>
    		<add key="UCommerceAppDomainBaseDirectory" value="AppDomainBaseDirectory" />
    	</appSettings>
    
    
Ucommerce Aps - Vestergade 58N, 4th. floor - 8000 Aarhus C - Denmark
Phone +45 61 799 997 - Email [email protected] Ucommerce logo