System.Reflection.TargetInvocationException caught on creati

Posted by Community Admin on 04-Aug-2018 10:27

System.Reflection.TargetInvocationException caught on creating new Project

All Replies

Posted by Community Admin on 02-Feb-2016 00:00

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: 

Posted by Community Admin on 02-Feb-2016 00:00

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

Posted by Community Admin on 05-Feb-2016 00:00

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
 

Posted by Community Admin on 05-Feb-2016 00:00

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.

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

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().

Posted by Community Admin on 09-Dec-2016 00:00

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.

This thread is closed