Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

System.Runtime.InteropServices.SEHException when logging in with Facebook

Discussion in 'Windows' started by Kujo87, Jul 22, 2014.

  1. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Hi,

    I'm using the Chillsters Facebook SDK with WP8 which until now has been working great.

    I upgraded to 4.5.2p1 today to fix the issue with DLLs not loading, but since then, I'm stuck with this exception that stops me from being able to log in. When I click on my login button from the UI, it opens the Facebook app on my phone, but then I get this exception.

    Code (csharp):
    1.  
    2. Exception: External component has thrown an exception.
    3. Type: System.Runtime.InteropServices.SEHException
    4. Module: UnityEngine
    5. InnerException: <No Data>
    6. AdditionalInfo:<No Data>
    7.    at UnityEngine.Internal.$Calli.Invoke90(Int32 arg0, Int64 arg1, IntPtr method)
    8.    at UnityEngine.MonoBehaviour.StartCoroutine_Auto(IEnumerator routine)
    9.    at UnityEngine.MonoBehaviour.StartCoroutine(IEnumerator routine)
    10.    at Facebook.WindowsPhoneFacebook.Login(String scope, FacebookDelegate callback)
    11.    at LoginManager.FacebookLogin()
    12.    at tk2dUIItem.Release()
    13.    at tk2dUIManager.CheckInputs()
    14.    at tk2dUIManager.Update()
    15.    at tk2dUIManager.$Invoke30(Int64 instance, Int64* args)
    16.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    The WindowsPhoneFacebook.Login method is as follows:

    Code (csharp):
    1.  
    2. public override void Login(string scope = "", FacebookDelegate callback = null)
    3. {
    4.     if(FacebookWP8.IsLoggedIn){
    5.         //If logged in then do nothing.
    6.         return;
    7.     }
    8.     else if(!FacebookWP8.IsLoggedIn && FacebookWP8.AccessToken.Length > 0){
    9.         //if AccessToken is only avaiable then Complete login (get UserID)
    10.         StartCoroutine(LoginComplete());
    11.     }
    12.     else{
    13.         FacebookWP8.Login(scope);
    14.         StartCoroutine(CheckLoginLoop()); //Start LoginCheck for login complete.
    15.     }
    16.     cb = callback;
    17. }
    18.  
    19.  
    20. private IEnumerator CheckLoginLoop(){
    21.     //Checks every one second to se if login is half done.
    22.     while(true){
    23.         yield return new WaitForSeconds(1f);
    24.         if(!FacebookWP8.IsLoggedIn && FacebookWP8.AccessToken.Length > 0){
    25.             //if AccessToken is only avaiable then Complete login (get UserID)
    26.             StartCoroutine(LoginComplete());
    27.             break;
    28.         }
    29.     }
    30. }
    31.  
    32. private IEnumerator  LoginComplete(){
    33.  
    34.     accessToken = FacebookWP8.AccessToken;
    35.     string url = "https://graph.facebook.com/me?method=get&access_token=" + accessToken;
    36.     WWW www = new WWW(url);
    37.     yield return www;
    38.     if(www.error != null)
    39.     {
    40.         Debug.LogError("www.error");
    41.         Logout();
    42.     }
    43.     else if(www.text.Contains("first_name")){
    44.         //If Data comes back then get User ID and Save it. Also be sure to save AccessToken
    45.         var dict = Facebook.MiniJSON.Json.Deserialize(www.text) as Dictionary<string,object>;
    46.         FacebookWP8.UserID = (string)dict["id"];
    47.         userId = FacebookWP8.UserID;
    48.         FacebookWP8.SaveUserIDToken();
    49.         FacebookWP8.SaveAccessToken();
    50.     }
    51.     else{
    52.         //Token is not valid. Delete session. Set to not logged in;
    53.         Logout();
    54.     }
    55.  
    56.     isLoggedIn = FacebookWP8.IsLoggedIn;
    57.  
    58.     if(cb != null)
    59.         cb(new FBResult((isLoggedIn) ?  "Login sucessful" : "Login failed", null));
    60.      
    61. }
    62.  
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Please report a bug. This needs deep investigation.
    Can you reproduce it on small project, that does only that?
     
  3. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Will do... working on one now
     
  4. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    I'm not able to repo the bug in a simple app - even adding some of my other plugins... Would a bug with my full project still be of any use?
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    If you did a clean build and error still occurs, then it's probably a bug in AssemblyConverter. If it's easy to reproduce, then I think the full project will suit too.
    Thanks.
     
  6. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Do you need the Unity project or would the Visual Studio output be sufficient? If the latter, could you PM me the FTP directory that I can upload to?
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    No, the Unity project is better.
     
  8. Kujo87

    Kujo87

    Joined:
    Sep 16, 2013
    Posts:
    160
    Bug uploaded now - Case 621860
     
  9. BlackPanda

    BlackPanda

    Joined:
    Jan 24, 2014
    Posts:
    78
    Any news about this bug? I got one too.
     
  10. kujo

    kujo

    Joined:
    Aug 19, 2013
    Posts:
    106
    It appears to have been fixed with 4.5.3p3. After updating to that version, I don't have the issue anymore
     
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Last thing I see in this bug is that it got fixed since 4.5.3p1.
     
  12. BlackPanda

    BlackPanda

    Joined:
    Jan 24, 2014
    Posts:
    78
    Oh! I'm now on 4.6.0b17.

    Edit: Sorry guys. The error is something else, not the bug said above. No need to spend your time on this. :)