Unity IoC exception with latest nopCommerce bits

Topics: General
May 26, 2011 at 7:25 PM

I followed the instructions to add nopCommerce on the C1 web site. Everything seemed to go well except when I added the connection string to ConnectionStrings.config.

I receive the following exception when navigating to/refreshing a page on my C1 site:

[NullReferenceException: Object reference not set to an instance of an object.]
   NopSolutions.NopCommerce.BusinessLogic.Infrastructure.IoC.Resolve() +154
   NopSolutions.NopCommerce.BusinessLogic.NopContext.get_WorkingLanguage() +705
   NopSolutions.NopCommerce.BusinessLogic.Profile.MembershipHttpModule.Application_AuthenticateRequest(Object sender, EventArgs e) +3516
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +266

I tested the connection string using a UDL file and connectivity to SQL Express or SQL Enterprise (remote server) tests fine.

Any idea, or should I post on the nopCommerce site?



May 31, 2011 at 9:08 AM

What's the name of your ConnectionString

May 31, 2011 at 9:17 AM

must be something like this:

	<add name="NopSqlConnection" connectionString="Your connection string here" />


May 31, 2011 at 11:55 AM

Here is the exact string I tried.


<add name="NopSqlConnection" connectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=administrator;Initial Catalog=NopCommerce;Data Source=ZOE\SQLEXPRESS" />


Jun 1, 2011 at 8:14 AM

Where is the value for "connectionString" from? Is it neccessary to use a Provider SQLOLEDB with MS SQL? Can you use a "normal" MS SQL Connection String like so:

<add name="NopSqlConnection" connectionString="Data Source=ZOE\SQLEXPRESS;Initial Catalog=nopCommerce;Integrated Security=SSPI;Persist Security Info=False;User ID=user;Password=pass;Connect Timeout=120" />

You should encrypt the connectionStrings section when specifying blank user/pass in the file! Take a look here: http://davidhayden.com/blog/dave/archive/2005/11/17/2572.aspx

Jun 1, 2011 at 1:48 PM

The <connectionStrings> element is contained within the ConnectionStrings.config file, which is referenced within the web.config; a common idiom.

The exact string you suggest was the first one I tried. The IT manager at the customer I am working for told me he was unable to get the latest version of nopCommerce and the 2.0 release of C1 working unless SQL Server (Standard) was on the same server as C1. I have tried SQL Express on the same VM, and SQL Enterprise on another server, but I always get the same exception. If I remove the <add> element, then C1 works fine, and nopCommerce is effectively offline. I'll try the nopCommerce baord - if they have one...


Jun 3, 2011 at 2:38 PM
Edited Jun 3, 2011 at 2:38 PM

you have Integrated Security=SSPI in your connection string, SSPI will take the identity of the App Pool running the service, in IIS it will be MachineName\NetworkService and you can not authenticate local accounts to a remote system, therefore you are denied access. when you tested the connection string using that UDL utility it would have used your user account and I am assuming it's a AD account with access to the remote server.


for a web server your connection string should be

"Data Source=MyServerName;Initial Catalog=MyDataBase; User ID=SQLUserName; Password=Password;"

also if you are using EF or any linq add MultipulActivationSet=True; to the end