Search code examples
c#xamarin.formsdatagridsyncfusionargumentnullexception

Syncfusion Datagrid crashes Xamarin IOS application due to initiallising of control


I have a Xamarin application in which I have included the Syncfusion Datagrid control. I am trying to deploy this to an IOS simulator in visual studio. I have added the NuGet package and included a community license. However, it wasn't displaying on the screen. To fix this I added the following line of code, as advised by https://www.syncfusion.com/forums/137574/no-visible-data-grid-on-ios-platform-only.

Syncfusion.SfDataGrid.XForms.iOS.SfDataGridRenderer.Init();

However, this now results in my application crashing with the only debugger info being:

main.cs:

static void Main(string[] args)
{
      // if you want to use a different Application Delegate class from "AppDelegate"
      // you can specify it here.
      UIApplication.Main(args, null, "AppDelegate"); #System.NullReferenceException: 'Object reference not set to an instance of an object'
}

AppDelegate.cs:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
      global::Xamarin.Forms.Forms.Init();
      Syncfusion.SfDataGrid.XForms.iOS.SfDataGridRenderer.Init();
      LoadApplication(new App());

      return base.FinishedLaunching(app, options);
}

If I haven't given you enough info about my setup please just ask and I will happily provide it. :)

Thanks in advance!


Solution

  • I don't know what the cause of the problem was, however, by downgrading my Xamarin.Forms and Xamarin.Essentials package to versions 4.5.0.495 and 1.3.1 respectively I no longer got the error and the screen was displayed properly.

    I figured this out by making a new test project and trying to recreate my code. Then I tried running it and it worked. Thus I changed the versions of my original code to the versions that worked in the project that was generated by a Xamarin template.

    Thanks everyone for their help :)