+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Exception thrown at CatalogManager.GetManager()

Exception thrown at CatalogManager.GetManager()

3 posts, 0 answered
  1. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    14 Dec 2015
    Link to this post

    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: 
  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    30 Sep 2016
    17 Dec 2015
    Link to this post
    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
     
  3. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    04 Jan
    Link to this post

    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.

3 posts, 0 answered