System.Reflection.TargetInvocationException caught on creating new Project - Bugs & Issues - Bugs & Issues - Progress Community

System.Reflection.TargetInvocationException caught on creating new Project

 Bugs & Issues

System.Reflection.TargetInvocationException caught on creating new Project

  • System.Reflection.TargetInvocationException caught on creating new Project
  • private Product MakeProduct2()

    Product product = new Product();
    product.Title.SetString(CultureInfo.CurrentCulture, "title");
    return product;

    Crash at SetString (trace at end of this).

    VS2015 SP1

    Sitefinity 8.2.5910.0


    System.Reflection.TargetInvocationException was unhandled by user code
      Message=Exception has been thrown by the target of an invocation.
           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(Type type, Boolean nonPublic)
           at System.Activator.CreateInstance(Type type)
           at Telerik.Sitefinity.Model.DataExtensions.get_AppSettings()
           at Telerik.Sitefinity.Model.DataExtensions.GetString(IDynamicFieldsContainer dataItem, String fieldName)
           at Telerik.Sitefinity.Ecommerce.Catalog.Model.Product.get_Title()
           at Certas.Sitefinity.Application.SitefinityCms.Tests.SitefinityProductRepositoryTests.MakeProduct2() in C:\Workspaces\GitHub\Certas\Certas.Sitefinity.Application.SitefinityCms.Tests\SitefinityProductRepositoryTests.cs:line 86
           at Certas.Sitefinity.Application.SitefinityCms.Tests.SitefinityProductRepositoryTests.CreateProduct_Returns_Guid() in C:\Workspaces\GitHub\Certas\Certas.Sitefinity.Application.SitefinityCms.Tests\SitefinityProductRepositoryTests.cs:line 31
           Message=Object reference not set to an instance of an object.
                at Telerik.Sitefinity.Abstractions.ObjectFactory.GetArgsByName(String name, Type baseType)
                at Telerik.Sitefinity.Configuration.Config.VerifySectionRegistered(Type sectionType, String sectionName)
                at Telerik.Sitefinity.Configuration.Config.GetSectionInternal(Type sectionType, Boolean safeMode, String sectionName)
                at Telerik.Sitefinity.Configuration.Config.GetSectionPrivate(Type sectionType, Boolean safeMode, String sectionName)
                at Telerik.Sitefinity.Configuration.Config.GetSectionPrivate[TSection](Boolean safeMode)
                at Telerik.Sitefinity.Configuration.Config.Get[TSection](Boolean safeMode)
                at Telerik.Sitefinity.Configuration.Config.Get[TSection]()
                at Telerik.Sitefinity.Abstractions.AppSettings..ctor()

  • Additional: This is in a Nunit testing session and I am using DI/IoC in the main project.
  • Hi Tim,

    Can you try to create a product/product depending on your needs as described in the respective article:

    I hope this helps.

    Svetoslav Manchev
    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
  • I started from that example.

    In-house we use dependency-injection extensively and need to Mock classes to support testing, we follow TDD as a standard development paradigm.

  • Did you ever solve this Tim? Unit tests in a Sitefinity project seem to be pretty problematic. I'm getting the same exception on Telerik.Sitefinity.Taxonomies.TaxonomyManager.GetManager().
  • Hi Arno,

    For some managers we managed to use the constructor that took a parameter which we had mocked, we use Moq normally. However in not all cases was this successful/possible.