我有以下vb.net代码,我试图从XML文件中读取内容并将其存储到自定义类列表中。当调试器尝试执行语句
时,我的应用程序崩溃 Dim serializer As New XmlSerializer(GetType(ItemInfo))
这里的ItemInfo是我用过的一个类。如果我尝试GetTyp(ItemInfo),我得到了所需的属性,只是XML序列化器没有初始化
我的完整代码如下:
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
调试窗口的输出:
'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'.
任何可以帮助我在这里进步的指针?
答案 0 :(得分:0)