We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Null Pointer Exception : SerializeToJson(Object inputObject)

Hi,
i am traying to implement Synchfusion Diagram. I tried to follow the steps indicated in the tutorial ( http://www.syncfusion.com/downloads/support/forum/119501/ze/Create_Your_First_Diagram_in_MVC-43006509 ).
Unfortunately the following Exception keeps raising:
   L'exception System.NullReferenceException n'a pas été gérée par le code utilisateur
  HResult=-2147467261
  Message=La référence d'objet n'est pas définie à une instance d'un objet.
  Source=Syncfusion.EJ
  StackTrace:
       à Syncfusion.JavaScript.Shared.Serializer.SerializeObject.SerializeToJson(Object inputObject)
       à Syncfusion.JavaScript.Shared.Serializer.SerializeObject.SerializeToJson(Object input, String ID)
       à Syncfusion.JavaScript.Control.Serialize(Object model)
       à Syncfusion.JavaScript.Control.RenderJson()
       à Syncfusion.JavaScript.Control.Raw()
       à Syncfusion.JavaScript.Control.ToHtmlString()
       à System.Web.HttpUtility.HtmlEncode(Object value)
       à System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content)
       à System.Web.WebPages.WebPageBase.Write(Object value)
       à ASP._Page_Views_Diagram_RenderDiagram_cshtml.Execute() dans c:\Users\administrateur\Desktop\*********\FS_RH\FS_RH_PL\Views\Diagram\RenderDiagram.cshtml:ligne 15
       à System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
       à System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
       à System.Web.WebPages.StartPage.RunPage()
       à System.Web.WebPages.StartPage.ExecutePageHierarchy()
       à System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       à System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
       à System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
       à System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
       à System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
       à System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       à System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
  InnerException:

I am using .NET MVC 5 in my project. My code (Controller and View) are attached.

Thank you.
 

Attachment: View__Controller_Synchfusion_Diagram_b4097b61.rar

3 Replies

SG Shyam G Syncfusion Team March 1, 2016 12:56 PM UTC

Hi Aymen,

The reported issue occurs only if the viewData(ViewData["diagramModel"]) value is null in the view page(.cshtml page) as highlighted in the below code example. So please check in the below sample and get back to us if you are still facing issues at your end.

Code example:

@Html.EJ().Diagram("DiagramContent", ViewData["diagramModel"] as DiagramProperties)

Sample:http://www.syncfusion.com/downloads/support/forum/123238/ze/mvcgettingstartedsample275702938

Regards,
Shyam G


AD aymen drine March 1, 2016 04:54 PM UTC

Hi Shyam G,
I checked the ViewData value and it's not Null.

        @{ var s = ViewData["diagramModel"];}
        @Html.EJ().Diagram("Diagram1", s as DiagramProperties)
Please check
the below Attachment:

Attachment: SyncfusionMvcApplication6_4f675505.rar


SG Shyam G Syncfusion Team March 2, 2016 12:50 PM UTC

Hi Aymen,

In your sample, we got the compilation error due to misspelling of the ViewData in the controller page(DiagramController.cs). you have set as ViewDataData instead of using ViewData. We have modified it correctly in your sample and provided below. Still if an issue occurs at your end, please provide us more details such as video and screenshot of controller, cshtml page. So that we can analyze further and provide a better solution. Please refer to the sample and video below.

Sample: http://www.syncfusion.com/downloads/support/forum/123238/ze/SyncfusionMvcApplication6272299172

Video:http://www.syncfusion.com/downloads/support/forum/123238/ze/nullpointervideo-51639309

Regards,
Shyam G

Loader.
Live Chat Icon For mobile
Up arrow icon