Hello guys,
Please help me out with one issue that I am having. I am using NopCommerce 1.6. In this When I called a method GetAllDiscounts(Null) or anything that have values in DiscountTypeEnum like GetAllDiscounts(Discounttypeenum.AssignedToOrderSubTotal); or whatever I am getting a null refrence exception on the last line of below code.
bool showHidden = NopContext.Current.IsAdmin;
string key = string.Format(DISCOUNTS_ALL_KEY, showHidden, discountType);
object obj2 = NopCache.Get(key);
if (DiscountManager.CacheEnabled && (obj2 != null))
{
return (DiscountCollection)obj2;
}
int? discountTypeId = null;
if (discountType.HasValue)
discountTypeId = (int)discountType.Value;
var dbCollection = DBProviderManager<DBDiscountProvider>.Provider.GetAllDiscounts(showHidden, discountTypeId);
In debug mode "F11" is also not working when I put a break-point on the last line of above code. I am bit frustrated so please help me out.
Exact error that I am getting is
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.
Source Error:
Line 301: discountTypeId = (int)discountType.Value;
Line 302:
Line 303: var dbCollection = DBProviderManager<DBDiscountProvider>.Provider.GetAllDiscounts(showHidden, discountTypeId);
Line 304: var discounts = DBMapping(dbCollection);
Line 305:
Source File: C:\Users\dev02\Documents\Projects\Bewoop\Libraries\Nop.BusinessLogic\Promo\Discounts\DiscountManager.cs Line: 303
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
NopSolutions.NopCommerce.BusinessLogic.Promo.Discounts.DiscountManager.GetAllDiscounts(Nullable`1 discountType) in C:\Users\dev02\Documents\Projects\Bewoop\Libraries\Nop.BusinessLogic\Promo\Discounts\DiscountManager.cs:303
NopSolutions.NopCommerce.BusinessLogic.Promo.Discounts.DiscountManager.HasDiscountsWithCouponCode() in C:\Users\dev02\Documents\Projects\Bewoop\Libraries\Nop.BusinessLogic\Promo\Discounts\DiscountManager.cs:280
NopSolutions.NopCommerce.Web.Modules.OrderSummary.BindDataBuyCart(ShippingOption shippingOption) in C:\Users\dev02\Documents\Projects\Bewoop\Bewoop.com\Modules\OrderSummary.ascx.cs:79
NopSolutions.NopCommerce.Web.Modules.OrderSummary.BindData(Boolean isCheckoutPage, ShippingOption shippingOptionBuy, Int32 buyPaymentMethodID, Int32 sellPaymentMethodID) in C:\Users\dev02\Documents\Projects\Bewoop\Bewoop.com\Modules\OrderSummary.ascx.cs:285
NopSolutions.NopCommerce.Web.ShoppingCartPage.Page_Load(Object sender, EventArgs e) in C:\Users\dev02\Documents\Projects\Bewoop\Bewoop.com\ShoppingCart.aspx.cs:33
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
NopSolutions.NopCommerce.Web.BaseNopPage.OnLoad(EventArgs e) in C:\Users\dev02\Documents\Projects\Bewoop\Bewoop.com\Controls\BaseNopPage.cs:68
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Thanks
Yogesh