locked
SilverLight application Code: 4004 RRS feed

  • Question

  • I noticed odd behavior after applying changes to the Closing method on a screen. If I have multiple screens open and I click on the X on a screen tab that is not in focus I get the error listed in the title of this post.  However; if I first click on the tab (bringing the screen associated with the tab into focus) and then click the X, the close works normally.

    The code containing the changes I made to the close method can be found at the end of this thread. http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/c70fb024-9968-483a-af15-df503eeba243

    Any ideas?  Do I need to put a check in the closing method to trap the error? If yes... what is the proper format?  

    Monday, May 20, 2013 5:29 PM

All replies

  • This is an un-handled exception ...

    wrap your closing logic in a try catch and place a break point on the catch. 

    Likely your attempting to access a null value, more than likely screens is null.

    thus screens.count will fail or ActiveScreens is null thus lync statement will fail.

    Check for nulls prior to coding against any instance

    Cheers


    Johnny Larue, http://www.softlandingcanada.com




    • Edited by John Kears Monday, May 20, 2013 6:28 PM
    Monday, May 20, 2013 6:26 PM
  • Thank you for your reply.

    I tried putting a Try Catch around the code where the error was happening but it did not produce a useful result however, in the process I realized that clicking on the X on the tab of a screen that was not in focus did in fact execute the closing method for the screen but part of the closing method was a ShowMessageBox and I assume being that the screen was not in focus the system didn't know where to display the MessageBox... thus the program halt.

    I don't know if my solution to the problem is optimal but all I did to solve it was to issue a ShowScreen command just before the ShowMessageBox and all is right in Mudville again.  :)

    Thanks

    Ed

         

    Thursday, May 23, 2013 3:40 PM