The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Under what circumctances does catch (Exception ex) not really catch all? (unrelated to WCF) RRS feed

  • General discussion

  • My crash reproting system is telling me that an exception reached the Unhandled Exception handler, and looking at the code that originates this, I can't see how this is happening.. The code is fully synchronous.

    Here's the code:

     

     

    1 private void LoadUserData()  
    2 {  
    3     try 
    4     {  
    5         UserData = UserData.Deserialize(UserDataFileName, true);  
    6  
    7         // We succeeded. Backup the file, if possible.  
    8         if (IsoFile.Store.FileExists(UserDataFileName))  
    9         {  
    10             try 
    11             {  
    12                 IsoFile.CopyFile(UserDataFileName, UserDataFileBackupName);  
    13             }  
    14             catch (Exception ex)  
    15             {  
    16                 EventManager.Current.ShipAssert("LoadUserData.Backup", ex);  
    17             }  
    18         }  
    19     }  
    20     catch (Exception ex)  
    21     {  
    22         string currentFile = "";  
    23         try 
    24         {  
    25             currentFile = IsoFile.ReadAllLines(UserDataFileName);  
    26         }  
    27         catch (Exception exInner)  
    28         {  
    29             currentFile = "Exception when trying to read file: " + exInner.ToString();  
    30         }  
    31 }  
    32

    And yet, when UserData.Deserialize() throws, the exception somehow makes its way to the Unhandled Exception handler (I colored the two calls LoadUserData/Deserialize() in red in the callstack below:

    1 System.InvalidOperationException: There is an error in XML document (129, 54). ---> System.InvalidOperationException: There is an error in XML document (129, 54). ---> System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: value, item, VotedUrls, UserData. Line 129, position 54.    at   
    2 System.Xml.XmlTextReaderImpl.Throw(Exception e)    at   
    3 System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString, String arg)    at   
    4 System.Xml.XmlTextReaderImpl.Throw(Int32 pos, Int32 res, String resString, String arg)    at   
    5 System.Xml.XmlTextReaderImpl.ThrowUnclosedElements()    at   
    6 System.Xml.XmlTextReaderImpl.ParseElementContent()    at   
    7 System.Xml.XmlTextReaderImpl.Read()    at   
    8 System.Xml.XmlTextReader.Read()    at   
    9 System.Xml.XmlReader.ReadEndElement()    at   
    10 System.Xml.Serialization.XmlSerializationReader.DeserializePrimitiveElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)    at   
    11 System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)    at   
    12 System.Xml.Serialization.XmlSerializationReader.DeserializeElement(Accessor accessor, Fixup fixup)    at   
    13 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)    at   
    14 SocialEbola.Shared.Utils.SerializableDictionary`2.ReadXml(XmlReader reader)    at   
    15 System.Xml.Serialization.XmlSerializationReader.DeserializeSerializableElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)    at   
    16 System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)    at   
    17 System.Xml.Serialization.XmlSerializationReader.DeserializeElementMember(MemberValueCollection members, Object fixupTarget, Hashtable internalState, Boolean& firstElement)    at   
    18 System.Xml.Serialization.XmlSerializationReader.deserializeMembers(MemberValueCollection members, Object fixupTarget)    at   
    19 System.Xml.Serialization.XmlSerializationReader.DeserializeComplexElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)    at   
    20 System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)    at   
    21 System.Xml.Serialization.XmlSerializationReader.DeserializeElement(Accessor accessor, Fixup fixup)    at   
    22 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)    at   
    23 System.Xml.Serialization.XmlSerializer.Deserialize(Stream stream)    at   
    24 SocialEbola.Lib.Serialization.SerializeHelper`1.Deserialize(Stream stream)    at   
    25 SocialEbola.Lib.Serialization.SerializeHelper`1.Deserialize(String file, Boolean createNew)    at   
    26 Fails.App.LoadUserData()    at   
    27 Fails.App.Application_Launching(Object sender, LaunchingEventArgs e)    at   
    28 Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()    at   
    29 Microsoft.Phone.Execution.NativeEmInterop.FireOnLaunching()     at   
    30 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)    at   
    31 SocialEbola.Shared.Utils.SerializableDictionary`2.ReadXml(XmlReader reader)    at   
    32 System.Xml.Serialization.XmlSerializationReader.DeserializeSerializableElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)    at   
    33 System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)    at   
    34 System.Xml.Serialization.XmlSerializationReader.DeserializeElementMember(MemberValueCollection members, Object fixupTarget, Hashtable internalState, Boolean& firstElement)    at   
    35 System.Xml.Serialization.XmlSerializationReader.deserializeMembers(MemberValueCollection members, Object fixupTarget)    at   
    36 System.Xml.Serialization.XmlSerializationReader.D  
    37  

    Saturday, November 12, 2011 9:59 PM