1

I am trying to setup test framework for my Sitecore solution. In that we are using fakedb to create the sitecore context. We are getting below exception on a static function.

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'Sitecore.SecurityModel.License.LicenseManager' threw an exception.
  Source=Sitecore.Kernel
  StackTrace:
   at Sitecore.SecurityModel.License.LicenseManager.DemandRuntime(Boolean acceptExpress)
   at Sitecore.Data.Managers.DefaultItemManager.get_FallbackProvider()
   at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database, SecurityCheck securityCheck)
   at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database)
   at Sitecore.Data.Managers.ItemManager.GetItem(String itemPath, Language language, Version version, Database database)
   at Foundation.Dictionary.Extensions.SitecoreExtensions.ImageFromMediaLibrary(SitecoreHelper helper, String mediaLibraryImagePath) in C:\Projects\New1\Foundation\Common\code\Dictionary\Extensions\SitecoreExtensions.cs:line 62
   at Feature.Menu.Areas.Order.Controllers.MenuController..ctor(IMapper mapper, IProductService productService, ISitecoreProductCategoryService sitecoreProductCategoryService, ISitecoreProductService sitecoreProductService, IContentProvider contentProvider, IOrderProvider orderProvider, IExceptionHandler exceptionHandler, ILanguageHelper languageHelper, IFavoriteItemService favoriteService, IGetProductDetailsQueryHandler productDetailsQueryHandler, IFavoriteItemsQueryHandler favoriteItemsQueryHandler, IStoreDetailsQueryHandler storeDetailsQueryHandler, IProductCommonService productCommonService, IProductService fndationIProductService, IRoundingRules foundationRoundingRules, IFavoriteItemService foundationFavoriteItemService, ISitecoreContext sitecoreContext, ICommonService commonService) in C:\Projects\New1\Feature\Menu\code\Areas\Order\Controllers\MenuController.cs:line 106

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
NullReferenceException: Object reference not set to an instance of an object.

2 Answers 2

1

You need to have a reference to Sitecore.nexus.dll

Method 1 : The Sitecore.Nexus assembly is in the Bin folder of your Sitecore website. Add a reference to this assembly from your test project.

Method 2 : Or you can use NuGet package.

In Visual Studio: Tools -> Options

In Options window find 'Nuget Package Manager' -> 'Package Sources'

enter image description here

Then click the green plus and fill Name and Source text fields.

Name one - whatever you want.

Source text field fill with https://sitecore.myget.org/F/sc-packages/api/v3/index.json

After that go to Tools->Nuget Package Manager->Manage Nuget Packages for Solution... In 'Package source' dropdown in right-top corner choose just add source. In my case it is 'Sitecore'. In search field type 'Sitecore.Nexus.Noreferences' or Sitecore.Nexus with no dependency:

enter image description here

Choose a project you want to install package and click Install button.

3
  • Thanks for the Response. I added already, but not working Oct 26, 2022 at 9:03
  • check your license.xml is not missing from your data folder (App_Data) Oct 26, 2022 at 9:17
  • License file is also present on the location which is mentioned on app.config. Oct 26, 2022 at 13:09
1

In my case, I have looked for a similar issue before and found that it was because the Sitecore.Nexus DLL was blocked.

So to resolve this, I removed that reference to Sitecore.Nexus from the project, unblocked the DLL, re-added the reference and it worked.

See below link to check for details on unblocking DLLs

http://www.limilabs.com/blog/unblock-dll-file

Finally, I would suggest you check that is there any config missing in your solution. Check if you have forgotten to add anything related.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.