CrossGeeks / FacebookClientPlugin

Facebook Client Plugin for Xamarin iOS and Android
MIT License
106 stars 32 forks source link

FacebookClientManager.Initialize(app, options); 'Object not set to an instance of an object' (runtime) #97

Closed danielkboyer closed 3 years ago

danielkboyer commented 3 years ago

Bug Information

FacebookClientManager.Initialize(app, options); 'Object not set to an instance of an object'

happens at runtime.

Version Number of Plugin: 2.21 Device Tested On: Iphone 12, using xamarin.hotrestart Simulator Tested On: none Version of VS: 4.8.04084

Version of Xamarin: 5.0.0.2083 Versions of other things you are using:

Steps to reproduce the Behavior

Follow the instructions for setup, run on ios device with Xamarin Hot Restart

Expected Behavior

The app should launch

Actual Behavior

The app crashes because of Initialization method

Code snippet

This is the line of code that crashes my project, I commented it out and everything ran smoothly (but I couldn't login through facebook) FacebookClientManager.Initialize(app, options);

Screenshotst

An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.FacebookClient.FacebookClientManager.Initialize (UIKit.UIApplication app, Foundation.NSDictionary options) <0x110893d00 + 0x0000e> in <1205be224660445f9710edd216b72dd4>:0 at Urfoodmobile.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0002c] in C:\Users\dedaq\source\repos\FormApp\iOS\AppDelegate.cs:47 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65 at Urfoodmobile.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\dedaq\source\repos\FormApp\iOS\Main.cs:17 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 ' The app has been terminated.

danielkboyer commented 3 years ago

I was able to reproduce this error using the sample app provided. I am looking for a solution now, if I find one I will submit a pull request, my earliest hypothesis is that the updated xamarin forms has a problem with the library. Will test this now.

danielkboyer commented 3 years ago

I didn't find a fix but I believe I found the problem. I am using Xamarin.ios hot restart, and they have a known limitation with referencing static libraries. I recently started using Xamarin.Stripe.IOS and it is giving me the same problem. There might be a fix that can get this library working with xamarin hot restart but this is not a bug with this library.