After migration to SDL Web 8, one piece of code in our C# TBB doesn't work anymore.
List<RepositoryLocalObject> componentList = newsKeyword.GetClassifiedItems(filter).ToList();
foreach (Component component in componentList)
{
//_log.Debug("value:" + component.Content.Value);
if (component.Schema.Title == "News")
{
//TO DO SOMETHING
}
}
The component.Schema
always returns null which triggers an error of:
Object reference not set to an instance of an object
But the fun fact is, after lots of attempts, we realized that the component.Schema
is no longer null ONLY when we try to get the component.Content.Value
(comment out the _log.Debug
line).
Did anyone encounter such issue before?