Exception thrown at CatalogManager.GetManager()

Posted by Community Admin on 04-Aug-2018 16:35

Exception thrown at CatalogManager.GetManager()

All Replies

Posted by Community Admin on 14-Dec-2015 00:00

Trying to get Products from Sitefinity but getting a "Object reference not set to an instance of an object" error.  The code looks like this;

public IList<Product> GetProducts()

var catalogManager = CatalogManager.GetManager();

List<Product> products = catalogManager.GetProducts().ToList();

return products;

Full error message:
System.Reflection.TargetInvocationException was unhandled by user code
  HResult=-2146232828
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance[T]()
       at Telerik.Sitefinity.Data.ManagerBase`1.GetManager[T](String providerName, String transactionName)
       at Telerik.Sitefinity.Data.ManagerBase`1.GetManager[T]()
       at Telerik.Sitefinity.Modules.Ecommerce.Catalog.CatalogManager.GetManager()
       at Sitefinity.Import.Repository.ImportProductRepository.GetProducts() in D:\Workspaces\ScrapArea\Certas.Sandpit\Sitefinity.Import.Repository\ImportProductRepository.cs:line 72
       at Sitefinity.Import.Repository.Tests.ImportProductRepositoryTests.Products_Are_Fetched() in D:\Workspaces\ScrapArea\Certas.Sandpit\Sitefinity.Import.Repository.Tests\ImportProductRepositoryTests.cs:line 24
  InnerException: 
       HResult=-2147467261
       Message=Object reference not set to an instance of an object.
       Source=Telerik.Sitefinity
       StackTrace:
            at Telerik.Sitefinity.Abstractions.Exceptions.HandleException(Exception exceptionToHandle, ExceptionPolicyName policy, Exception& exceptionToThrow)
            at Telerik.Sitefinity.Abstractions.Exceptions.HandleException(Exception exceptionToHandle, ExceptionPolicyName policy)
            at Telerik.Sitefinity.Data.ManagerBase`1.Initialize()
            at Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName, String transactionName)
            at Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName)
            at Telerik.Sitefinity.Modules.Ecommerce.Catalog.CatalogManager..ctor(String providerName)
            at Telerik.Sitefinity.Modules.Ecommerce.Catalog.CatalogManager..ctor()
       InnerException: 

Posted by Community Admin on 17-Dec-2015 00:00

Hi Tim,

Testing the sample seems works fine. Do you have any issues when open the products list in the backend (Ecommerce products)? Do you have the same issue when you get a list of other content types, e.g. News.

In addition, where this code is executed, in any custom control?  If so, can you provide this control here or open a support ticket?

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 04-Jan-2016 00:00

Hi Svetoslav,

Sorry for delay, been on vacation.

Error does not happen when the object is referenced from a controller, it was only happening when I was unit testing the repository separately using Nunit. I am now calling the methods in the controller for testing and that appears to be working OK.

Thanks.

This thread is closed