Getting error when trying to get items of Content Area : - media.Tracks 

Vote:
 

Hi,

I am using Opti CMS version 12.16.0 and getting issue as below:

value cannot be null. (Parameter 'culture')

When trying to get items of Content Area : - media.Tracks

Content Type is Media type for images

stack trace :
at EPiServer.DataAbstraction.Internal.LanguageBranchRepository.Load(CultureInfo culture)
  at EPiServer.DataAccess.Internal.ContentDB.LoadList(PropertyData property, ContentReference contentLink, CultureInfo language, String propertyScopeName, Nullable`1 includedPropertyDefinitionId)
  at EPiServer.DataAccess.Internal.ContentDB.<>c__DisplayClass99_0.<AssignDelayLoadedFactory>g__delayedLoader|0()
  at EPiServer.Core.Internal.LazyValueInitializer.EnsureInitialized[TReference](TReference& reference, Func`1& lazyValueFactory, Func`2 init)
  at EPiServer.SpecializedProperties.PropertyContentArea.get_ContentArea()

image

#296625
Feb 16, 2023 9:13
Vote:
 

Media Data does not implement ILocalizable, so cant have Language Specific versions. Are you doing something be-spoke which might be trying to retrieve language values and returning null as not supported ?

Might need to see more of the Stack Trace or even ths code to see where it could be going wrong.  

#296630
Feb 16, 2023 11:59
Vote:
 

Hi,

I am getting error in highlighted code.

      [AllowedTypes(typeof(IStandardVttMedia))]
        [Display(GroupName = ApplicationConstants.EditTabs.Content, Order = 1030, Name = "Tracks", Description = "List of video tracks: captions (for the deaf), chapter titles, descriptions (for the blind), subtitles (language translations), etc.")]
        public virtual ContentArea Tracks { get; set; }

public Video CreateVideo(IStandardVideoMedia standardVideo)
        {
            var sources = standardVideo?.AdditionalSources?.GetFilteredItemsOfType<IStandardVideoMedia>(_contentLoader) ?? new List<IStandardVideoMedia>();
             var tracks = standardVideo?.Tracks?.GetFilteredItemsOfType<IStandardVttMedia>(_contentLoader);

              var video = new Video()

               return video;

        }

#296675
Feb 17, 2023 6:44
Minesh Shah (Netcel) - Feb 17, 2023 10:11
What's the Interface IStandardVttMedia look like ? And can you share an Implementation of It ?

Im guessing you have used the following helper for GetFilteredItemsOfType from : https://world.optimizely.com/forum/developer-forum/Developer-to-developer/Thread-Container/2018/4/how-to-get-block-items-from-a-contentarea-based-on-its-type/
Vote:
 

using EPiServer.Core;

     public interface IStandardVttMedia : IContentMedia, ILocale
    {
        string Kind { get; set; }

         string Label { get; set; }
    }

Yes, we are using the same for GetFilteredItemsOfType.

#296684
Edited, Feb 17, 2023 10:17
Vote:
 

Do you have a specific ContentType defined that implements IStandardVttMedia? I believe this content type should also implement IContentData for that Helper to work. 
If you have a look at the base MediaData class you will see an example. 

#296686
Feb 17, 2023 11:26
Vote:
 

This seems to be a bug in CMS12 and I just (5 min ago) created a support ticket to EPi regarding this.

I have noticed that when getting a ContentArea property from a MediaData content type this sometimes will throw an ArgumentNullException in EPiServer.DataAbstraction.Internal.LanguageBranchRepository.Load(CultureInfo culture)

This bug is very tricky to reproduce, since it seems to be very dependant on how the content has been loaded. E.g. if the MediaData is loaded in edit mode or by ContentLoader.Get this bug does not occur. And also loading the MediaData  "a way that works" refreshes the cache - making loading the MediaData "ways that does not work" to suddenly work.

I have been able to reliably reproduce the bug by:

  1. Downloading latest Alloy project (2023-03-14)
  2. Add a ContentArea property (in my example i named it TestContentArea) to the existing ImageFile content type
  3. Create a ImageFile instance in SiteAssetsRoot folder and add two or more pages to the ContentArea "TestContentArea"
  4. Add code to fetch the image file by using ContentLoader.GetChildren<ImageFile>(SiteDefinition.Current.SiteAssetsRoot).Where(x => x.TestContentArea != null).ToList(); I did this in StartPageController. Also, note that .ToList() is needed, since .Where returns IEnumerable.
  5. Restart the app. Cache needs to be reset if the ImageFile has been loaded in edit mode.
  6. StartPage will now throw ArgumentNullException

What I believe (but havent 100% verified) is:

  • This bug only seems to occur for ContentTypes that aren't culture specific (like MediaData)
  • Seems to have something to do with lazy loading content for ContentAreas
#298290
Edited, Mar 14, 2023 9:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.