0

I have the following vb.net code where I am trying to read contents from a XML file and store it onto a list of custom class. My app crashes when the debugger tries to execute the statement

 Dim serializer As New XmlSerializer(GetType(ItemInfo))

Here ItemInfo is a class I have used. If I try the GetTyp(ItemInfo) I get the desired properties, it is just that the XML serializer doesn't get initialized

My complete code is as follows:

Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim fi As System.IO.FileInfo = New IO.FileInfo(System.IO.Path.Combine(Application.StartupPath, "items.xml"))
    If fi.Exists Then
        Dim lst As New List(Of ItemInfo)
        Dim serializer As New XmlSerializer(GetType(ItemInfo)) ->Stuck here 
        Dim fs As New IO.FileStream("items.xml", IO.FileMode.Open)
        Dim reader As System.Xml.XmlReader = System.Xml.XmlReader.Create(fs)
        lst = serializer.Deserialize(reader)
        fs.Close()
    End If
End Sub

the output from the debug window:

'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Users\vparthasarat\Documents\Visual Studio 2013\Projects\temme\temme\bin\Debug\temme.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualBasic\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    The thread 0x1d3c has exited with code 259 (0x103).
    The thread 0x2164 has exited with code 259 (0x103).
    The thread 0x1c1c has exited with code 259 (0x103).
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Users\vparthasarat\Documents\Visual Studio 2013\Projects\temme\temme\bin\Debug\temme.exe'. Symbols loaded.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Remoting\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll'. Symbols loaded.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Users\vparthasarat\Documents\Visual Studio 2013\Projects\temme\temme\bin\Debug\System.Windows.Forms.Calendar.dll'. Symbols loaded.
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'Microsoft.GeneratedCode'. 
    A first chance exception of type 'System.InvalidOperationException' occurred in System.Xml.dll
    'temme.vshost.exe' (CLR v4.0.30319: temme.vshost.exe): Loaded 'C:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll'. Module was built without symbols.
    The program '[2408] temme.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

Any pointers that would help me progress here?

Venkat Raman
  • 103
  • 14
  • Post the error message and stacktrace – Sriram Sakthivel Jun 02 '14 at 05:43
  • That doesn't help. What is the error message and stack trace of the exception? What you posted looks like copied from output window from VS. am asking about details of the exception. Without that we cant help. – Sriram Sakthivel Jun 02 '14 at 05:49
  • I really didn't get any exception on the screen...the application simply terminated and this is all is what I got on my output window :\ – Venkat Raman Jun 02 '14 at 05:50
  • Enable this [setting](http://msdn.microsoft.com/en-us/library/d14azbfh.aspx), it will break when there is an exception. Then you'll be able to get the details, Updated the link, please check again. – Sriram Sakthivel Jun 02 '14 at 05:52
  • It says `A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll` – Venkat Raman Jun 02 '14 at 05:55

1 Answers1

0

I did a reading of the link below and found that it is normal to get this exception..

XmlSerializer giving FileNotFoundException at constructor

Thanks @sriram for guiding me through this :)

Community
  • 1
  • 1
Venkat Raman
  • 103
  • 14