Search Unity

[SOLVEDIssue with unity and App42 'System.AccessViolationException' occurred in UnityEngineProxy.dll

Discussion in 'Scripting' started by tmanallen, Nov 28, 2015.

  1. tmanallen

    tmanallen

    Joined:
    Nov 8, 2009
    Posts:
    395
    Just wondering if anyone has come up with this issue? 'System.AccessViolationException' occurred in UnityEngineProxy.dll
    Code (csharp):
    1.  
    2. Here is the code that I am using: right out of App42 sample with some changes of course.
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using System;
    6. using UnityEngine.SocialPlatforms;
    7. using System.Collections;
    8. using System.Collections.Generic;
    9. using System.Net;
    10. using System.Text.RegularExpressions;
    11. using com.shephertz.app42.paas.sdk.csharp;
    12. using com.shephertz.app42.paas.sdk.csharp.game;
    13.  
    14.  
    15.  
    16. public class GetHighScores :MonoBehaviour {
    17.  
    18.     ScoreBoardService scoreBoardService = null; // Initialising ScoreBoard Service.
    19.     Constants cons = new Constants();
    20.     public string success, columnName, rankersBox, saveBox, txt_user, errorLable, box, txt_score;
    21.     public static string playerRank;
    22.     public static string playerScore , playerName;
    23.     public static int txt_max;
    24.     public bool saveButton, leaderBoardButton;
    25.     public GUIStyle mySkin;
    26.  
    27.  
    28.  
    29.  
    30.     void Start()
    31.     {
    32.         App42API.Initialize(cons.apiKey, cons.secretKey);
    33.         App42API.SetOfflineStorage(true, 20);
    34.         App42Log.SetDebug(true);
    35.  
    36.  
    37.     }
    38.  
    39.     public  void ShowScores()
    40.     {
    41.    
    42.         txt_max = 10;
    43.         // Clearing Data From Response Box.
    44.         success = "";
    45.         playerRank = "";
    46.         playerName = "";
    47.         playerScore = "";
    48.         box = "";
    49.         errorLable = "";
    50.  
    51.         scoreBoardService = App42API.BuildScoreBoardService(); // Initializing scoreBoardService.
    52.         int max = txt_max;  // Maximum Number Of TOP RANKERS.
    53.  
    54.         //Getting Top Scorers , By Using App42 Scoreboard Service.
    55.         //Method Name->GetTopNRankers(gameName, max);
    56.         //Param->gameName(Name Of The Game, Which Is Created By You In AppHQ.)
    57.         //Param->max(Provide Max Number "N" Of Scorers.)
    58.         //Param->Callback(callback for success/exception.);
    59.         scoreBoardService.GetTopNRankers(cons.gameName, max, new CallBackScores());
    60.         leaderBoardButton = true;
    61.  
    62.     }
    63.     public void SaveScores()
    64.     {
    65.         // Clearing Data From Response Box.
    66.         success = "";
    67.         box = "";
    68.         playerRank = "";
    69.         playerName = "";
    70.         playerScore = "";
    71.         columnName = "";
    72.         errorLable = "";
    73.  
    74.         if (txt_user == null || txt_user.Equals(""))
    75.         {
    76.             box = "User Name Can Not Be Blank: ";
    77.             return;
    78.         }
    79.         string userName = txt_user;  // Name Of The USER Who Wants To Save Score.
    80.      
    81.         double score = double.Parse(txt_score);     // Value Of The Score.
    82.  
    83.         scoreBoardService = App42API.BuildScoreBoardService(); // Initializing scoreBoardService.
    84.                                                                //Saving User Score , By Using App42 Scoreboard Service.
    85.                                                                //Method Name->SaveUserScore(gameName, userName, score);
    86.                                                                //Param->gameName(Name Of The Game, Which Is Created By You In AppHQ.)
    87.                                                                //Param->userName(Name Of The User For Which You Want To Save Score.)
    88.                                                                //Param->score( Data Type "double" Value Of Score.)
    89.                                                                //Param->Callback(callback for success/exception.);
    90.         scoreBoardService.SaveUserScore(cons.gameName, userName, score,new CallBackScores());
    91.         saveButton = true;
    92.  
    93.     }
    94.     void OnGUI()
    95.     {
    96.         // For Setting Up ResponseBox.
    97.         //GUI.Box(new Rect(450, 40, 250, 175), box);
    98.         //GUI.Label(new Rect(470, 50, 200, 200), columnName);
    99.         //GUI.Label(new Rect(470, 70, 200, 200), success);
    100.         GUI.Label(new Rect(350, 130, 350, 350), playerRank,mySkin);
    101.         GUI.Label(new Rect(540, 130, 350, 350), playerName,mySkin);
    102.         GUI.Label(new Rect(770, 130, 350, 350), playerScore,mySkin);
    103.  
    104.  
    105.         // Label For EXCEPTION Message .
    106.         GUI.Label(new Rect(250, 250, 700, 400), errorLable);
    107.  
    108.         //======================================================================================
    109.         //---------------------------- Saving User Score.---------------------------------------
    110.         //======================================================================================
    111.      
    112.         GUI.Label(new Rect(20, 40, 200, 20), "User Name");
    113.         txt_user = GUI.TextField(new Rect(100, 40, 200, 20), txt_user,9);
    114.         GUI.Label(new Rect(20, 70, 200, 20), "Score");
    115.    
    116.        txt_score = GUI.TextField(new Rect(100, 70, 200, 20), txt_score.ToString());
    117.         txt_score = Regex.Replace(txt_score, @"[^0-9]", "");
    118.  
    119.      
    120.      
    121.  
    122.     }
    123.  
    124.     public class CallBackScores : App42CallBack
    125.     {
    126.      
    127.  
    128.         public void OnSuccess(object response)
    129.         {
    130.             var nxtLine = System.Environment.NewLine;
    131.  
    132.        
    133.          
    134.                 Game gameResponseObj = (Game)response;
    135.            
    136.                 IList<Game.Score> topRankersList = gameResponseObj.GetScoreList();
    137.                 if (topRankersList.Count > 0)
    138.                 {
    139.  
    140.  
    141.                     for (int i = 0; i < gameResponseObj.GetScoreList().Count; i++)
    142.                     {
    143.                         string scorerName = gameResponseObj.GetScoreList().GetUserName();
    144.                         double scorerValue = gameResponseObj.GetScoreList().GetValue();
    145.  
    146.                         playerRank = playerRank + (i + 1).ToString() + nxtLine; //Getting Rank Of Player.
    147.                         playerName = playerName + scorerName + nxtLine; //Getting Player Name.
    148.                         playerScore = playerScore + scorerValue.ToString() + nxtLine; // Getting Score Value.
    149.  
    150.                     }
    151.                 }
    152.             }
    153.         public void OnException(Exception e)
    154.         {
    155.             App42Log.Console("Exception : " + e);
    156.         }
    157.     }
    158. }
    159.  
    This is what was in my call Stack..
    [External Code]

    Really don't know if anyone here uses App42 and I am awaiting a reply on their end also but I am trying to cover all my basis, thanks in advance.
     
    Last edited: Nov 28, 2015
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Code tags?
     
  3. tmanallen

    tmanallen

    Joined:
    Nov 8, 2009
    Posts:
    395
    There you go, have you had this before? Any suggestions?
     
  4. tmanallen

    tmanallen

    Joined:
    Nov 8, 2009
    Posts:
    395
    Ok found the issue, App42 isn't compatible with Windows 10 UWP, just wish that if you don't know the answer don't reply back just to get code and then run. If anyone else is interested this backend API doesn't work with UWP just yet hopefully it will, because everything works with Window 8.1.