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

Forums / Bugs & Issues / System.Reflection.TargetInvocationException caught on creating new Project

System.Reflection.TargetInvocationException caught on creating new Project

4 posts, 0 answered
  1. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    02 Feb
    Link to this post

    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
      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(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
      InnerException: 
           HResult=-2147467261
           Message=Object reference not set to an instance of an object.
           Source=Telerik.Sitefinity
           StackTrace:
                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()
           InnerException: 

  2. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    02 Feb
    Link to this post
    Additional: This is in a Nunit testing session and I am using DI/IoC in the main project.
  3. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    22 Sep 2016
    05 Feb
    Link to this post
    Hi Tim,

    Can you try to create a product/product depending on your needs as described in the respective article:
    http://docs.sitefinity.com/for-developers-create-products
    http://docs.sitefinity.com/for-developers-create-product-types

    I hope this helps.

    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
     
  4. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    05 Feb in reply to Svetoslav Manchev
    Link to this post

    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.

4 posts, 0 answered