0

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!

Minirobbo
  • 61
  • 1
  • 8
  • have you added a try/catch block around the suspect line of code? – Jason Jun 21 '20 at 12:35
  • @Jason I have, however because the UIApplication.Main function is a very broad command i havent been able to get anything useful... Do you know a better way to gather debugging information? – Minirobbo Jun 21 '20 at 13:44
  • add appcenter.ms crash reporting. The crash is not actually happening in Main, it just looks like that when an unhandled crash occurs. – Jason Jun 21 '20 at 13:48
  • Sorry @Jason ive never used that before... do you have a link / tutorial i can follow to show me how to use this to find the root of the error? Thanks again – Minirobbo Jun 21 '20 at 14:03
  • https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/xamarin#423-xamarinforms – Jason Jun 21 '20 at 14:28

3 Answers3

1

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

Minirobbo
  • 61
  • 1
  • 8
1

I too have experienced this same issue; after recent updates, my app crashed with a null exception on the main.cs in iOS. I finally isolated and resolved what was triggering the issue.

The problem occurred when I populated a SfDataGrid with more rows than could fit on a (cross platform, iOS) simulator screen; this would trigger a crash as soon as I tried to scroll vertically or horizontally. If the number of rows was less than the screen size, however, it didn't crash. The app also worked fine a week or so ago.

It turns out that there appears to be a bug in the latest release of Xamarin.Forms version 4.6.0.968. By downgrading Xamarin.Forms to version 4.6.0.847, the problem was resolved.

The following link provides further details On this issue:

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Mojo
  • 11
  • 2
  • Assuming you didn’t accidentally delete your own answer, it was likely deleted by either reviewers or a high-reputation user for not meeting Stack Overflow’s standards for an answer. If the text was identical to this repost, it _may_ have been due to the _tense_ of your first sentence; on quick review, it sounded like you _still_ had the problem. We get a lot of answers saying “I have this issue too” without actually providing a resolution. I’ve reworded your answer so it’s clearer that you were able to isolate and resolve this. While I was at it, I also made some small edits for readability. – Jeremy Caney Jun 27 '20 at 17:27
0

You do not need the renderer initialization if you are using Xamarin.iOS platform and not the cross-platform.

In case, if you are using the iOS version of Xamarin.Forms, then refer the getting started documentation here to know the step by step configuration of the DataGrid component. Confirm that you have installed the Syncfusion.Xamarin.SfDataGrid NuGet package.

In case, if you are using the Xamarin.iOS platform itself, then please refer the documentation here for the step by step configurations and be sure that you have installed the Syncfusion.Xamarin.SfDataGrid.IOS package.

I hope that helps.

Harikrishnan
  • 1,474
  • 2
  • 11
  • 25
  • sorry i should have been more clear. my application is a cross platform xamarin forms app, thus it has generic, IOS, Android, and UWP parts. I am only concerned about the IOS part as it is the only part i have had trouble with... :) – Minirobbo Jun 21 '20 at 13:25
  • I just checked and everything seems to be up to scratch regarding what you have highlighted... Any other ideas? – Minirobbo Jun 21 '20 at 13:34
  • Try comparing your sample with the example demo here to narrow down. https://github.com/SyncfusionExamples/DataGrid-GettingStarted-in-Xamarin-Forms – Harikrishnan Jun 21 '20 at 13:54
  • Because without knowing what is thrown as null, it is not possible to proceed further. Or maybe try uploading a demo of what you tried, that would be easier to help. – Harikrishnan Jun 21 '20 at 13:55