Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Windows Phone Exception

Discussion in 'Windows' started by bjohnson8704, Jun 14, 2014.

  1. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    Hi, I'm trying to port our game 15 Coins to Windows Phone and I'm getting the following error while trying to run the game in the device simulator.


    The following code is what is throwing the exception as far as I can tell(it appears to be breaking any time ChangeGameState() is called):

    Code (JavaScript):
    1. enum GameState{MainMenu, Pregame, Play, Options, CoolDown, GameOver, Help, Tutorial, ControlChooser};
    2. static var myGameState : GameState;
    3. static var oldGameState : GameState;
    4.  
    5. function Start () {
    6.     ChangeGameState(GameState.MainMenu);
    7. }
    8.  
    9. function ChangeGameState (gs : GameState) : IEnumerator {
    10.     oldGameState = myGameState;
    11.     myGameState = gs;
    12.     switch(myGameState){
    13.     case GameState.Pregame:
    14.         BeginCountDown();
    15.     break;
    16.     case GameState.MainMenu:
    17.         if(oldGameState == GameState.Options){
    18.             HideOptions();
    19.         }
    20.     #if UNITY_ANDROID  
    21.         AdmobAd.Instance().HideBannerAd();
    22.         EasyAmazonAdsManager.HideBanner();
    23.     #endif
    24.         ShowMainMenu();
    25.     break;
    26.     case GameState.GameOver:
    27.         if(oldGameState == GameState.CoolDown){
    28.             HideGame();
    29.         }
    30.         else if(oldGameState == GameState.Options){
    31.             HideOptions();
    32.         }
    33.     break;
    34.     case GameState.Options:
    35.         if(oldGameState == GameState.MainMenu){
    36.             HideMainMenu();
    37.         }
    38.         if(oldGameState == GameState.GameOver){
    39.             HideGameOver();
    40.         }
    41.         ShowOptions();
    42.     break;
    43.     case GameState.Play:
    44.         HideMainMenu();
    45.     break;
    46.     case GameState.CoolDown:
    47.         CoolDown();
    48.     break;
    49.            
    50.     }
    51.    
    52. }


    My technical knowledge is quite limited and while I can usually dig up a solution to fix whatever issue I come across, I haven't been able to find a solution for this problem, so any help would be greatly appreciated! Please let me know if there's any more information that I could give that could help in figuring out the issue.

    Thanks,

    Blake Johnson
     
  2. stephan7

    stephan7

    Joined:
    Jul 3, 2012
    Posts:
    44
  3. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    Built to Windows Phone using Unity 4.5.0. Originally developed in Unity 4.3.4 on Mac(don't think this would matter?).

    I had various plugins for iOS & Android versions, but removed all plugins from the project in the Unity Editor, so it's just game code.
     
  4. stephan7

    stephan7

    Joined:
    Jul 3, 2012
    Posts:
    44
    Perhaps you can try the following to get more information:
    - open your project from Visual Studio
    - switch from 'Master' to 'Debug' configuration
    - right click on the project and select 'Properties'
    - in the 'Debug' tab you can set the debugger type to 'native'
    - start your project from Visual Studio.

    Perhaps you can get more information this way (e.g. a numeric error code (HRESULT) should be associated with the exception).

    --
    Download Sonemix on Windows Phone: http://www.windowsphone.com/s?appid=e363ad1f-fa36-4348-a89d-5283d62270f5
    Download
    Sonemix on iOS: http://appstore.com/sonemix
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Hi, do you have a stacktrace for the exception?
     
  6. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    Here is the exception alert after following stephan7's instructions:


    Tautvydas, forgive my ignorance if this isn't what you requested(as my knowledge on the subject is near 0), but here is the Debug Ouput:


    I really appreciate the help as I'm completely lost when it comes to this. Thank you both! :)
     
  7. stephan7

    stephan7

    Joined:
    Jul 3, 2012
    Posts:
    44
    The error message indicates that a network routine of the OS was called with an invalid argument. A multicast address identifies a group of computers (e.g. all routers) in your network segment. I guess you are not calling such functionality, so there is a big chance that the problem is not in your code.

    You could try to deploy to an actual Windows Phone device if that's possible.

    That would make sure that it's not a kind of configuration problem (Hyper-V settings for the device emulator or some network setting on the PC or Parallels or Fusion or whatever you are using).


    Stephan

    --
    Download Sonemix on Windows Phone: http://www.windowsphone.com/s?appid=e363ad1f-fa36-4348-a89d-5283d62270f5
    Download
    Sonemix on iOS: http://appstore.com/sonemix
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Hi,

    the networking error message is harmless: it is caused by the fact that emulator cannot connect to the editor for profiling. It does not crash the application.

    Could you switch to managed debugger (project properties -> debug -> UI Task -> select "Managed Only") and then post the log again?
     
  9. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    Here is the log with UI Task set to "Managed Only"

    Thanks!
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    That's exactly what I needed.

    What do you do at GameStateManager.Start()? It seems that's where the exception is originating.
     
  11. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    GameStateManager.Start() function:

    Code (JavaScript):
    1.  
    2. function Start () {
    3.     gamesStartedSession = 0;
    4.     gamesEndedSession = 0;
    5.     optionsMoveType = 1;
    6.     instance = this;
    7.     ChangeGameState(GameState.MainMenu);
    8.  
    9. }
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    That's odd. You don't seem to call StartCoroutine at all here, I've no clue how that ends up on the callstack. Is ChangeGameState a normal function?
     
  13. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    ChangeGameState is as follows:

    Code (JavaScript):
    1. function ChangeGameState (gs : GameState) : IEnumerator {
    2.     oldGameState = myGameState;
    3.     myGameState = gs;
    4.     switch(myGameState){
    5.     case GameState.Pregame:
    6.         BeginCountDown();
    7.     break;
    8.     case GameState.MainMenu:
    9.         if(oldGameState == GameState.Options){
    10.             HideOptions();
    11.         }
    12.     #if UNITY_ANDROID
    13.         AdmobAd.Instance().HideBannerAd();
    14.         EasyAmazonAdsManager.HideBanner();
    15.     #endif
    16.         ShowMainMenu();
    17.     break;
    18.     case GameState.GameOver:
    19.         if(oldGameState == GameState.CoolDown){
    20.             HideGame();
    21.         }
    22.         else if(oldGameState == GameState.Options){
    23.             HideOptions();
    24.         }
    25.     break;
    26.     case GameState.Options:
    27.         if(oldGameState == GameState.MainMenu){
    28.             HideMainMenu();
    29.         }
    30.         if(oldGameState == GameState.GameOver){
    31.             HideGameOver();
    32.         }
    33.         ShowOptions();
    34.     break;
    35.     case GameState.Play:
    36.         HideMainMenu();
    37.     break;
    38.     case GameState.CoolDown:
    39.         CoolDown();
    40.     break;
    41.          
    42.     }
    43.  
    44. }
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Alright, this definitely looks like a bug from the first sight. Can you report it so we could take a deeper look?

    EDIT: As a workaround, could you change the ChangeGameState function return value so it's not an IEnumerator?
     
    Last edited: Jun 17, 2014
  15. bjohnson8704

    bjohnson8704

    Joined:
    Jan 30, 2011
    Posts:
    54
    Sorry for the delayed response, but the workaround you suggested worked perfectly. :) I will try to submit a bug report this weekend(I have limited access to a Windows PC, so I'm not sure exactly when I'll be able to get to it).

    Really appreciate the help!
     
  16. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Facing similar issue in another script.
    Unity Ver :4.5.4p3
    Platform : WP8


    Exception: External component has thrown an exception.
    Type: System.Runtime.InteropServices.SEHException
    Module: UnityEngine
    InnerException: <No Data>
    AdditionalInfo:<No Data>
    at UnityEngine.Internal.$Calli.Invoke32(Int32 arg0, Boolean arg1, IntPtr method) at UICarCustomization.$Invoke27(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
     
  17. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    Note, that SEHException is a very generic exception type, thrown for various reasons.

    When providing stack traces, capture the meaninfully large part of it. Anything containing $ character in it is generated glue-code, so capture a larger parts containing lines without $ chars.
     
  18. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    I am getting more SEHException elsewhere in my game.
    Unity Ver :4.5.4p3
    Platform : WP8

    Kindly check the attached log file...!
     

    Attached Files:

  19. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    It looks to be related to unloading unused assets. Some objects are destroyed even when they are used.
    You can prevent that by calling Object.DontDestoyOnLoad().
    Can't say more without more info on what you use in your project.