Null Reference Exception when widget references a content it

Posted by Community Admin on 04-Aug-2018 14:37

Null Reference Exception when widget references a content item that has been deleted.

All Replies

Posted by Community Admin on 11-Feb-2013 00:00

I receive the following exception when I create a widget, select a content item, and then delete the content item. In my case, I created a custom module and am using the default designer.

[NullReferenceException: Object reference not set to an instance of an object.]
   DynamicModule.ns.Wrapped_OpenAccessDynamicModuleProvider_71b59295779e47afa80daee85cb0ca48.GetDataItem(Type itemType, Guid id) +322
   Telerik.Sitefinity.DynamicModules.DynamicModuleManager.GetDataItem(Type itemType, Guid id) +87
   Telerik.Sitefinity.DynamicModules.Web.UI.Frontend.DynamicContentView.IsSingleItem() +277
   Telerik.Sitefinity.DynamicModules.Web.UI.Frontend.DynamicContentView.CreateChildControls() +120
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

You can easily reproduce this by following these simple steps:
1. Create a custom module.
2. Create a content item for the custom module.
3. Add the widget for the module you created to a page.
4. Click "edit" on the widget and under the content tab select "Only particular X only...". Select the content item you created.
5. Save your changes and publish the page.
6. View the page on the front-end. (it should not error)
7. Delete the content item you selected.
8. View the page on the front-end. (it throws an exception)

In my own code I have try/catches around GetItem calls on the DynamicModuleManager because it throws null reference exceptions if you try to get an item that no longer exists. Unfortunately, I have a lot of widgets that don't use my custom code and they use Sitefinity's default designers.

I am using Sitefinity 5.0.2523.0 SE. Is there anything I can do to mitigated this? On a large site there is not a good way for the client to know everywhere they referenced a content-item. I would rather Sitefinity handle its absence gracefully rather than blowing up the entire page.

Posted by Community Admin on 14-Feb-2013 00:00


This issue was occuring in sitefinity 5.0 it is already fixed and there is no longer error thrown, when there is a single item selected which has been already deleted the widget will display no items as selected. Update to sitefnity 5.3 to get the fix.

Stanislav Velikov
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items

This thread is closed