How to: Troubleshoot the error message “Value cannot be null. Parameter name: stream” when working with custom Sitefinity widgets

When developing custom Sitefinity widgets, you want to make sure that the ascx file used for the display can be correctly accessed when the page is being rendered.

The following error message is not hugely helpful when trying to hunt down the reason your application has broken.

Value cannot be null.
Parameter name: stream

Even worse, you may find that the debugger is of no use.

image

 

You should already be noticing where this is heading. The references to EnsureChildControls and TemplateParser point you to the right direction.

If you were building your new widgets as part of the SitefinityWebPart, things would have been rather different. However, if you’re using a separate project for your widgets, you will want to make sure that the new project is referenced in the SitefinityWebApp project (make sure you’re adding a reference from the Solution, not a reference to the .dll of the new project in the bin folder) and –here’s the important bit– ensure that the .ascx used for the new widget is set to “build as an embedded resource”! Any other option in the “build action” drop down will result in the template not being available at the time the page is being rendered:

sitefinityCustomWidget_BuildAction

 

 

However, if your error message is slightly different, i.e. if you’re getting a “Value cannot be null. Parameter name: type“, you will want to read these: 1, 2.

MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.