Xamarin iOS example crashes with "Object reference not set to an instance of an object"

J Julius Mueller 2 years 2 months ago
945 1 0

Hello,
I'm trying to create a Xamarin RFID app for Android and iOS.
Before that we had developed two separated native apps for these os.

For the start I create some test apps based on the example apps provided by Zebra.

The Android example works fine for me. I can use it.

But the iOS example doesn't work for me.
I tested the app on two iPhone with iOS 15.5 and 15.6. Both are with the same issue.

I'm using the Xamarin-SDK v1.0.10.0 from
https://www.zebra.com/us/en/support-downloads/software/developer-tools/…

I initialized a RfidSdk-Object.
If I try to get the RfidSdk.ReaderManager or the RfidSdk.Version I got a exception: Object reference not set to an instance of an object.

This is my Main.cs:

public class Application
{
static void Main( string[] args )
{
RfidSdk sdk = new RfidSdk();
Console.WriteLine( sdk.Version ); // This is crashing

UIApplication.Main( args, null, typeof( AppDelegate ) );
}
}

I digged little bit deeper with a Decompiler. In there I saw, that the Version property call the ReaderManager prorperty. If the ReaderManager property is called, the internal API should initialize.

There is a call of srfidSdkFactory.CreateRfidSdkApiInstance wich should return a native API. In my case the call always return NULL.

I tested this line in my Main method:

IsrfidISdkApi api = srfidSdkFactory.CreateRfidSdkApiInstance; // returns NULL

Has anyone a idea how I can fix this issue?

In the Release documentation is written, that the SDK for iOS is up to version 14.x. Maybe is the problem that my iPhones are over version 15? But our native app are running fine on the devices.

Thank you!
Greets,
Julius

Please Register or Login to post a reply

1 Replies

S Sonny Thao

Hi @Julius Mueller,

Were you able to solve this issue?

I, too, have encountered calls to srfidSdkFactory.CreateRfidSdkApiInstance returning null.  This is occurring with the Zebra demo apps that come with the iOS SDK (for Xamarin and .NET MAUI) and the result is that a splash screen appears for a short time then the apps close - the apps never fully launch.  The root cause is an 'Object reference not set to an instance of an object.' error that results from a call to apiInstance.SrfidSetDelegate(instance); because apiInstance is null.  And apiInstance is null because it's assigned by a call to srfidSdkFactory.CreateRfidSdkApiInstance which returns null.  This occurs in the NativeRfidSdkHandler.cs class for both the Xamarin and .NET MAUI demo apps.

For now, I've submitted this issue with the iOS SDK to Zebra support and am working with them to, hopefully, find a solution.  In the meantime, I wanted to search the web for anyone else encountering my same issue and was glad and sad to see that you have.  I will post back here, should Zebra be able to sort out a solution.

For now, I'm glad that we've been able to confirm for one another that there's an issue with the iOS SDK.

Sonny

CONTACT
Can’t find what you’re looking for?