Search code examples
episerver

Null pointer-exception (FunctionTypeList.ascx) i Composer module-plugin for EPiServer


I have installed the Composer-module for EPiServer on an EPiServer CMS 6 R2-site deployed at IIS 7. I have configured the web.config according to the instructions. I can view a page in 'Composer edit'-mode.

I get the following error when I try to access the Composer-plugin in Admin-mode (which is used to register Composer-blocks).

How do I solve this?: Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 60:                             <ItemTemplate>
Line 61:                                 <nobr>  
Line 62:                                    <asp:Label ID="Label1" runat="server" 
Line 63:                                         ToolTip ='<%#DataBinder.Eval(Container.DataItem, "Description")%>'
Line 64:                                         Text = '<%# Utils.TrimDescription(DataBinder.Eval(Container.DataItem, "Description").ToString(),20).ToHtmlEncoded()%>'/>         


Source File: c:\EPiServer\Sites\Skien\Dropit\Plugin\Extension\UI\Admin\Controls\FunctionTypeList.ascx    Line: 62

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   ASP.dropit_plugin_extension_ui_admin_controls_functiontypelist_ascx.__DataBinding__control19(Object sender, EventArgs e) in c:\EPiServer\Sites\Skien\Dropit\Plugin\Extension\UI\Admin\Controls\FunctionTypeList.ascx:62
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +303
   System.Web.UI.Control.DataBindChildren() +12659735
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
   System.Web.UI.Control.DataBindChildren() +12659735
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
   System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +295
   System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +4780
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +95
   System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +19
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +222
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +313
   System.Web.UI.Control.DataBindChildren() +12659735
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
   System.Web.UI.Control.DataBindChildren() +12659735
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
   System.Web.UI.Control.DataBindChildren() +12659735
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
   System.Web.UI.Control.DataBindChildren() +12659735
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
   Dropit.Extension.UI.Admin.Controls.FunctionTypeList.DataBind() +646
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929 

Solution

  • This post by Mari Jørgensen describes the same issue on some of the other controls in Composer.

    Basically EPiServer will return an empty string if the Description is not set, while PageTypeBuilder returns null.

    The solution is to modify the line of code to return string.Empty if the Description is null:

    <%# Utils.TrimDescription(DataBinder.Eval(Container.DataItem, "Description") as string ?? String.Empty,20).ToHtmlEncoded()%>'/>