System.NullReferenceException Error

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

System.NullReferenceException Error

Post by pdeluca » Mon Dec 22, 2008 4:05 pm

I'm getting the following error when trying to access my site:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Here's the Stack Trace:
NullReferenceException: Object reference not set to an instance of an object.]
CommerceBuilder.Taxes.TaxCalculator.Calculate(Basket basket) +63
CommerceBuilder.Orders.Basket.Recalculate() +54
ConLib_MiniBasket.Page_PreRender(Object sender, EventArgs e) +52
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnPreRender(EventArgs e) +2066972
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360

Here's the weird part: Multiple machines on the same network. One accesses just fine, the others (including a Mac) get the error. I've looked at the connection string every way I can think of and I can't figure out why it comes up on one but not the others.

Any ideas?

Thanks!

pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

Re: System.NullReferenceException Error

Post by pdeluca » Mon Dec 22, 2008 6:18 pm

UPDATE:

Got home, tried to access the site, same error. Then I went to the site IP address/Admin. Came up no problem, logged in, and was able to view the store. What would make that error intermittent?

pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

Re: System.NullReferenceException Error

Post by pdeluca » Tue Dec 23, 2008 6:41 am

UPDATE #2:

When I go to ipaddress/Admin the login page comes up. If I then go to the Default page WITHOUT LOGGING IN the site comes up.

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: System.NullReferenceException Error

Post by sohaib » Tue Dec 23, 2008 7:14 am

Hello,

Can you please post information from Help->About on which version and build number you are using?
Also please let me know if there are any customizations you have made.
Can you also please describe the setup of your taxes?

Can you reproduce the problem with an anonymous user?
Can you reproduce this when you register as a new user?
Do you reproduce this when you use login using an existing user account?

pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

Re: System.NullReferenceException Error

Post by pdeluca » Tue Dec 23, 2008 8:08 am

Here's the version info:

PLATFORM: ASP.NET
VERSION: 7.1
BUILD: 10875

AjaxControlToolkit: 1.0.10301.0
CommerceBuilder: 7.0.10576.0
CommerceBuilder.AbleCommerceTax: 7.1.0.0
CommerceBuilder.AustraliaPost: 7.1.0.0
CommerceBuilder.AuthorizeNet: 7.0.9764.0
CommerceBuilder.CanadaPost: 7.0.0.0
CommerceBuilder.CCH: 7.0.0.0
CommerceBuilder.Configuration: 7.0.10576.0
CommerceBuilder.CyberSource: 7.0.9764.0
CommerceBuilder.DataClient.Api: 1.0.0.21
CommerceBuilder.DataClient.Csv: 1.0.0.0
CommerceBuilder.DHL: 7.0.8825.0
CommerceBuilder.DHLInternational: 7.1.0.0
CommerceBuilder.ECB: 7.0.0.0
CommerceBuilder.FedEx: 7.0.9725.0
CommerceBuilder.FRBNY: 7.0.0.0
CommerceBuilder.GoogleCheckout: 7.0.10052.0
CommerceBuilder.InternetSecure: 7.0.9764.0
CommerceBuilder.LinkPoint: 7.0.9764.0
CommerceBuilder.Paradata: 7.0.9764.0
CommerceBuilder.PayFlowPro: 7.0.10061.0
CommerceBuilder.PayJunction: 7.0.9764.0
CommerceBuilder.PayPal: 7.1.10840.0
CommerceBuilder.Protx: 7.1.10124.0
CommerceBuilder.Services: 7.0.10576.0
CommerceBuilder.SkipJack: 7.0.9764.0
CommerceBuilder.UPS: 7.0.10041.0
CommerceBuilder.USPS: 7.0.9728.0
CommerceBuilder.Web: 7.0.10576.0
ComponentArt.Web.UI: 2007.1.1566.3
CyberSource.Base: 2.0.0.0
CyberSource.Clients: 5.0.2.0
CyberSource.Clients.XmlSerializers: 5.0.2.0
CyberSource.WSSecurity: 2.0.0.0
CybsWSSecurityIOP: 1.0.0.0
edtFTPnet: 1.2.4.0
FredCK.FCKeditorV2: 2.5.2912.21007
ICSharpCode.SharpZipLib: 0.85.5.452
LinkPointTransaction: 1.0.1797.29766
log4net: 1.2.10.0
Microsoft.Practices.EnterpriseLibrary.Common: 2.0.0.0
Microsoft.Practices.EnterpriseLibrary.Data: 2.0.0.0
Microsoft.Practices.ObjectBuilder: 1.0.51205.0
Microsoft.Web.Preview: 1.2.61025.0
NVelocity: 7.0.8530.0
PaygatewayNET: 3.0.0.0
paypal_base: 4.2.1.0
PFProCOMLib: 1.0.0.0
PFProdotNET: 0.0.0.0
Validators: 1.0.0.0
WebChart: 1.1.1.6
wwHoverPanel: 1.85.0.0
Also please let me know if there are any customizations you have made.
Can you also please describe the setup of your taxes?
Can you reproduce the problem with an anonymous user?
Can you reproduce this when you register as a new user?
Do you reproduce this when you use login using an existing user account?
I have customized a few scriptlets and created some new ones, but modifications have been for layout and content only.
No taxes are set up yet.
I have not tried to reproduce the error as an anonymous or new user.
I have only logged in as admin, which does not produce the error.

Thanks!

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: System.NullReferenceException Error

Post by sohaib » Tue Dec 23, 2008 8:26 am

Are you still able to reproduce the bug in a situation?
When was the last time you were able to reproduce the bug?

Can you go to Configure->Taxes->Settings and let me know if you have taxes enabled or not?

pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

Re: System.NullReferenceException Error

Post by pdeluca » Tue Dec 23, 2008 8:46 am

Taxes are enabled. I just reproduced the error this morning on a machine by doing the following:

Accessing http://myipaddress/Default.aspx, the error occurs.
Backspace over Default.aspx and typing Admin, I get the admin login screen.
Backspace over everything except http://myipaddress, I get the default site page.

pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

Re: System.NullReferenceException Error

Post by pdeluca » Tue Dec 23, 2008 11:09 am

Seems to be session or cookie related. When I clear my browser cache, cookies, and authenticated sessions, the error returns. After reaching the admin page, I can navigate freely between the admin console and the default site with no error no matter if I log in or not.

pdeluca
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Mon Dec 22, 2008 3:54 pm

Re: System.NullReferenceException Error

Post by pdeluca » Sat Dec 27, 2008 6:16 pm

anyone?

gilesroberts
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Wed Nov 26, 2008 5:43 am

Re: System.NullReferenceException Error

Post by gilesroberts » Fri Jan 23, 2009 4:15 am

We've had the same issue. After some painstaking going back through the revisions of the software to see what changes caused the error we came to the following conclusion:

It's putting the mini basket on the front page. When you log in under a browser that hasn't been to Able Commerce before with no Able cookies, it falls over on the basket recalculate. I think this is caused by the mini basket recalculating within the page Page_PreRender method before the cookies have been created. When the Token.Instance.User is requested it returns a user with an id of 0 with a somehow invalid basket. The invalid basket goes pop when it's recalculated.

Our fix to ConLib/MiniBasket.ascx.cs is as follows:

//BUILD THE BASKET ON PRERENDER SO THAT WE CAN ACCOUNT
//FOR ANY PRODUCTS ADDED DURING THE POSTBACK CYCLE
protected void Page_PreRender(object sender, System.EventArgs e)
{
//PREPARE BASKET FOR DISPLAY
//**EGGHEAD**
if (Token.Instance.User.UserId != 0)
{
//**EGGHEAD**
Basket basket = Token.Instance.User.Basket;
basket.Package(true);
basket.Recalculate();

//VALIDATE THE BASKET
List<string> basketMessages = new List<string>();
bool basketValid = basket.Validate(out basketMessages);
//DISPLAY ANY WARNING MESSAGES
if (!basketValid)
{
Session["BasketMessage"] = basketMessages;
//Redirect to basket page where these error messages will be displayed
Response.Redirect("~/Basket.aspx");
}
BindBasket(basket);
//**EGGHEAD**
}
else
ShowBasket(false);
//**EGGHEAD**
}

joebeazelman
Lieutenant (LT)
Lieutenant (LT)
Posts: 78
Joined: Wed Mar 05, 2008 11:27 am

Re: System.NullReferenceException Error

Post by joebeazelman » Tue Apr 28, 2009 6:27 pm

I got the same error today after deleting all the demo products and importing my products via a custom SQL script. When I add a product to the basket I get the following error message:

{"Object reference not set to an instance of an object."}

I fired up another browser and did the same thing and I didn't receive an error. This is definitely session/cookie related. I am running:

PLATFORM: ASP.NET
VERSION: 7.0.2
BUILD: 11659

Has this bug been fixed or did I forget to call something after importing my products?

Post Reply