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.
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:
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.