I am experiencing strange behavior working with native FB library. My
observations are below. I am using the code located at
https://github.com/kevinmcmahon/monotouch-facebook but I don't believe the
issues are related to the code. It seems they are related to MonoTouch or my
lack of understanding of it.

1. When using the code (after setting APP ID), the code does FB login/logout
OK. In this version of the code, an instance of SessionDelegate used for
login is created in ctor of DemoAppViewController.

2. If I create an additional instance of SessionDelegate just before login
and use that for login, I get error. The modified login code in
DemoAppViewController is as follows

                void Login()
                {
                        var sessionDelegate = new SessionDelegate(this);
                        _facebook.Authorize(new string[]{"read_stream", 
"offline_access"},
sessionDelegate);
                }
The error display is below.

3. If I modify the same function like this, I get a different error. The
error is below the prev error.
                void Login()
                {
                        var sessionDelegate = new SessionDelegate(this);
                        for (int i = 0; i < 10; i++) {
                                int j = i*i;
                        }
                        _facebook.Authorize(new string[]{"read_stream", 
"offline_access"},
sessionDelegate);
                }

What am I doing wrong here? My purpose is to develop a robust code and
clearly I am missing something here. Thanks in advance.


Error for case 2:
==========
Stacktrace:

  at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging.bool_objc_msgSend_IntPtr
(intptr,intptr,intptr) <IL 0x00027, 0xffffffff>
  at FacebookSdk.Facebook.HandleOpenUrl (MonoTouch.Foundation.NSUrl) <IL
0x0002d, 0x000cf>
  at FacebookSDKExamples.AppDelegate.HandleOpenURL
(MonoTouch.UIKit.UIApplication,MonoTouch.Foundation.NSUrl) [0x0000a] in
/Users/vinay/Projects/monotouch-facebookbase/FacebookSDKExamples/FacebookSDKExamples/Main.cs:55
  at (wrapper runtime-invoke)
<Module>.runtime_invoke_void__this___object_object
(object,intptr,intptr,intptr) <IL 0x0005a, 0xffffffff>
  at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)
<IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038]
in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26
  at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in
/Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:31
  at FacebookSDKExamples.Application.Main (string[]) [0x00000] in
/Users/vinay/Projects/monotouch-facebookbase/FacebookSDKExamples/FacebookSDKExamples/Main.cs:15
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

        0   FacebookSDKExamples                 0x000dbcd4
mono_handle_native_sigsegv + 343
        1   FacebookSDKExamples                 0x0001a5c8
mono_sigsegv_signal_handler + 322
        2   libSystem.B.dylib                   0x92cc305b _sigtramp + 43
        3   ???                                 0xffffffff 0x0 + 4294967295
        4   FacebookSDKExamples                 0x00004dbf -[Facebook
handleOpenURL:] + 538
        5   ???                                 0x0ce15c00 0x0 + 216095744
        6   ???                                 0x0ce15af0 0x0 + 216095472
        7   ???                                 0x0ce0e465 0x0 + 216065125
        8   ???                                 0x0ce0e5eb 0x0 + 216065515
        9   FacebookSDKExamples                 0x0001a383 
mono_jit_runtime_invoke
+ 1332
        10  FacebookSDKExamples                 0x001f8145 mono_runtime_invoke +
137
        11  FacebookSDKExamples                 0x002a884f monotouch_trampoline 
+
2527
        12  UIKit                               0x01067125 -[UIApplication
_applicationOpenURL:payload:] + 342
        13  UIKit                               0x01065412 -[UIApplication
_callApplicationResumeHandlersForURL:payload:] + 131
        14  UIKit                               0x01076647 -[UIApplication
_handleApplicationResumeEvent:] + 1537
        15  UIKit                               0x01076039 -[UIApplication
handleEvent:withNewEvent:] + 4127
        16  UIKit                               0x0106dabf -[UIApplication
sendEvent:] + 71
        17  UIKit                               0x01072f2e
_UIApplicationHandleEvent + 7576
        18  GraphicsServices                    0x030e4992 PurpleEventCallback +
1550
        19  GraphicsServices                    0x030e4a19
PurpleEventSignalCallback + 42
        20  CoreFoundation                      0x01fc48ff
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
        21  CoreFoundation                      0x01f2288b 
__CFRunLoopDoSources0 +
571
        22  CoreFoundation                      0x01f21d86 __CFRunLoopRun + 470
        23  CoreFoundation                      0x01f21840 CFRunLoopRunSpecific 
+
208
        24  CoreFoundation                      0x01f21761 CFRunLoopRunInMode + 
97
        25  GraphicsServices                    0x030e31c4 GSEventRunModal + 217
        26  GraphicsServices                    0x030e3289 GSEventRun + 115
        27  UIKit                               0x01076c93 UIApplicationMain + 
1160
        28  ???                                 0x077f0d03 0x0 + 125766915
        29  ???                                 0x077f0ad4 0x0 + 125766356
        30  ???                                 0x077f00d4 0x0 + 125763796
        31  ???                                 0x077efeb6 0x0 + 125763254
        32  ???                                 0x077f007e 0x0 + 125763710
        33  FacebookSDKExamples                 0x0001a383 
mono_jit_runtime_invoke
+ 1332
        34  FacebookSDKExamples                 0x001f8145 mono_runtime_invoke +
137
        35  FacebookSDKExamples                 0x001fa82c 
mono_runtime_exec_main +
669
        36  FacebookSDKExamples                 0x001f9c16 
mono_runtime_run_main +
843
        37  FacebookSDKExamples                 0x000adf0f mono_jit_exec + 200
        38  FacebookSDKExamples                 0x0000d648 main + 4060
        39  FacebookSDKExamples                 0x0000c451 _start + 208
        40  FacebookSDKExamples                 0x0000c380 start + 40

Debug info from gdb:

dyld: could not load inserted library: /Users/vinay/Library/Application
Support/iPhone
Simulator/4.3.2/Applications/1A19A12A-F177-4D9B-ABAE-62A4EC88FBC3/FacebookSDKExamples.app/monotouch-fixes.dylib


=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


Error for case 3:
==========
Toplevel exception: System.MissingMethodException: No constructor found for
FacebookSDKExamples.SessionDelegate::.ctor(System.IntPtr)
  at System.Activator.CreateInstance (System.Type type, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[]
activationAttributes) [0x000f1] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:280 
  at System.Activator.CreateInstance (System.Type type, System.Object[]
args, System.Object[] activationAttributes) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:234 
  at System.Activator.CreateInstance (System.Type type, System.Object[]
args) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:229 
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr
klass) [0x0000d] in
/Developer/MonoTouch/Source/monotouch/monotouch/ObjCRuntime/Runtime.cs:167 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x0001f] in
/Developer/MonoTouch/Source/monotouch/monotouch/ObjCRuntime/Runtime.cs:210 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr) [0x00000]
in
/Developer/MonoTouch/Source/monotouch/monotouch/ObjCRuntime/Runtime.cs:227 
  at (wrapper native-to-managed)
MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr)
  at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:bool_objc_msgSend_IntPtr
(intptr,intptr,intptr)
  at FacebookSdk.Facebook.HandleOpenUrl (MonoTouch.Foundation.NSUrl url)
[0x00000] in <filename unknown>:0 
  at FacebookSDKExamples.AppDelegate.HandleOpenURL
(MonoTouch.UIKit.UIApplication application, MonoTouch.Foundation.NSUrl url)
[0x0000a] in
/Users/vinay/Projects/monotouch-facebookbase/FacebookSDKExamples/FacebookSDKExamples/Main.cs:55
 
  at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00038] in
/Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in
/Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:31 
  at FacebookSDKExamples.Application.Main (System.String[] args) [0x00000]
in
/Users/vinay/Projects/monotouch-facebookbase/FacebookSDKExamples/FacebookSDKExamples/Main.cs:15
 



--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/MonoTouch-unexpected-behaviors-with-native-FB-lib-tp3799298p3799298.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to