2.0 Error - Attempted to divide by zero.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
In a clean install of 2.0 - no demo data - after adding categories, manufacturers & products I'm getting Attempted to divide by zero. when browsing to a manufacturer page:

Server Error in '/' Application.

Attempted to divide by zero.

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.DivideByZeroException: Attempted to divide by zero.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[DivideByZeroException: Attempted to divide by zero.]
   Nop.Core.PagedList`1..ctor(IQueryable`1 source, Int32 pageIndex, Int32 pageSize) in F:\Own\NopCommerce\Sources\src\Libraries\Nop.Core\PagedList.cs:22
   Nop.Services.Catalog.ProductService.SearchProducts(Int32 categoryId, Int32 manufacturerId, Nullable`1 featuredProducts, Nullable`1 priceMin, Nullable`1 priceMax, Int32 relatedToProductId, Int32 productTagId, String keywords, Boolean searchDescriptions, Int32 languageId, IList`1 filteredSpecs, ProductSortingEnum orderBy, Int32 pageIndex, Int32 pageSize, Boolean showHidden) in F:\Own\NopCommerce\Sources\src\Libraries\Nop.Services\Catalog\ProductService.cs:350
   Nop.Web.Controllers.CatalogController.Manufacturer(Int32 manufacturerId, CatalogPagingFilteringModel command) in F:\Own\NopCommerce\Sources\src\Presentation\Nop.Web\Controllers\CatalogController.cs:914
   lambda_method(Closure , ControllerBase , Object[] ) +163
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +263
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +38
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +128
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +798650
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +798704
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

12 years ago
Found the root cause - I am creating the Manufacturers programatically and PageSize is defaulting to 0 - but guys we need to be checking for this condition
12 years ago
Great learning here - as I've run into multiple issues trying to programatically add a ton of records:  because of the EntityFramework and Code First model, the application handles defaults just fine - but if you're trying to build an import application for a specific product feed - you need to make sure all the defaults are set when adding entities.  It would help if the "default" values were setup in the DB as well so that if omitted from an add statement - they'd refelct the same values as if adding from the admin panel.
12 years ago
viperguynaz wrote:
In a clean install of 2.0 - no demo data - after adding categories, manufacturers & products I'm getting Attempted to divide by zero. when browsing to a manufacturer page:

Server Error in '/' Application.

Attempted to divide by zero.

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.DivideByZeroException: Attempted to divide by zero.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[DivideByZeroException: Attempted to divide by zero.]
   Nop.Core.PagedList`1..ctor(IQueryable`1 source, Int32 pageIndex, Int32 pageSize) in F:\Own\NopCommerce\Sources\src\Libraries\Nop.Core\PagedList.cs:22
   Nop.Services.Catalog.ProductService.SearchProducts(Int32 categoryId, Int32 manufacturerId, Nullable`1 featuredProducts, Nullable`1 priceMin, Nullable`1 priceMax, Int32 relatedToProductId, Int32 productTagId, String keywords, Boolean searchDescriptions, Int32 languageId, IList`1 filteredSpecs, ProductSortingEnum orderBy, Int32 pageIndex, Int32 pageSize, Boolean showHidden) in F:\Own\NopCommerce\Sources\src\Libraries\Nop.Services\Catalog\ProductService.cs:350
   Nop.Web.Controllers.CatalogController.Manufacturer(Int32 manufacturerId, CatalogPagingFilteringModel command) in F:\Own\NopCommerce\Sources\src\Presentation\Nop.Web\Controllers\CatalogController.cs:914
   lambda_method(Closure , ControllerBase , Object[] ) +163
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +263
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +38
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +128
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +798650
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +798704
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


Hello,

How did you solve this problem?

Thanx in advance!
Tesh
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.