Whenever you are trying to create a new user profile using Commerce Server SDK as shown below, it throws an error – “Object reference not set to an instance of an object”.
ProfileContext profiles= CommerceContext.Current.ProfileSystem;
You may face similar type of error when web.config is missing some of the HTTP modules which are responsible for populating commerce server context. A standard application includes following HTTP modules.
CommerceApplication
CommerceAuthentication
CommerceOrder
CommerceCatalog
CommerceProfile
CommerceExpressionEvaluator
CommerceCache
CommerceContentSelection
CommerceDataWarehouseAuthenticationModule
If you are developing commerce server site from beginning, you can refer to the following Microsoft material which describes the configuration settings of commerce server web.config application.
http://msdn.microsoft.com/en-us/library/ms960520.aspx
If you wish to know how to make it work, you need to ensure the following codes in commerce server application web.config file.
<configSections>
<sectionGroup name=”CommerceServer”>
<section name=”application” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceApplicationSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”authentication” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceAuthenticationSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”pipelines” type=”Microsoft.CommerceServer.Runtime.Configuration.CommercePipelineSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”caches” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceCacheSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”messageManager” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceMessageManagerSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”catalog” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceCatalogSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”orders” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceOrdersSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”profiles” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceProfilesSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”contentSelection” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceContentSelectionSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”commerceEvent” type=”Microsoft.CommerceServer.Runtime.Configuration.EventLoggerConfigurationHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<section name=”expressions” type=”Microsoft.CommerceServer.Runtime.Configuration.CommerceExpressionSectionHandler, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
</sectionGroup>
</configSections>
<!– COMMERCE SERVER CONFIGURATION SECTION
This signifies the beginning of the configuration of the Commerce Server .NET
Application Framework.
–>
<CommerceServer>
<application siteName=”EShop” debugLevel=”Checked”/>
</CommerceServer>
<appSettings/>
<connectionStrings/>
<system.web>
<httpModules>
<add name=”CommerceApplication” type=”Microsoft.CommerceServer.Runtime.CommerceApplicationModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceAuthentication” type=”Microsoft.CommerceServer.Runtime.CommerceAuthenticationModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceOrder” type=”Microsoft.CommerceServer.Runtime.Orders.CommerceOrderModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceCatalog” type=”Microsoft.CommerceServer.Runtime.Catalog.CommerceCatalogModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceProfile” type=”Microsoft.CommerceServer.Runtime.Profiles.CommerceProfileModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceExpressionEvaluator” type=”Microsoft.CommerceServer.Runtime.Targeting.CommerceExpressionModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceCache” type=”Microsoft.CommerceServer.Runtime.Caching.CommerceCacheModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add name=”CommerceContentSelection” type=”Microsoft.CommerceServer.Runtime.Targeting.CommerceContentSelectionModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
</httpModules></system.web>
If you like this post, please click on our sponsor advertisement.
