This code hangs my application!

L

Lars Netzel

Hi!

A button triggers the code..

I'm trying to learn about the XmlSerializer and when the code comes the try
statement it doesn' throw an exception, it goes into the
MsgBox(string_writer.ToString) and then the application hangs.. I never see
the MessageBox ...

'***************************************************************************
*****

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim myDataset As DataSet

myDataset = GlobalDataSets._codes

Dim xml_serializer As XmlSerializer

Dim string_writer As New StringWriter

' Create the XmlSerializer.

xml_serializer = New XmlSerializer(GetType(System.Data.DataSet))

' Make the serialization, writing it into the StringWriter.

xml_serializer.Serialize(string_writer, myDataset)

' Display the results.

Try

MsgBox(string_writer.ToString)

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

'***************************************************************************
******

Pease help/

Lars
 
L

Lars Netzel

Yeah, ... the Line that should display the messagebox.. but I think I know
wht the problem was.. the XML text I was expecting was HUGE... so I think
the messagebox was somehow thoring a fit cause it got to much stuff in the
promt parameter!

/Lars
 
C

CJ Taylor

Simple tip.

Add a System.Diagnostics.TextWriterTraceListner to either your trace
listener or debug listner at startup.

Such as

Trace.Listeners.Add(New System.Diagnostics.TextWriterTraceListener( _

String.Format("C:\LOGS\{0}_{1}.txt", Application.ProductName,
Now().ToFileTime()) _

))

Trace.AutoFlush = True

This way, you don't have to worry about messageboxes and you can just use
Trace.Writeline instead and it automatically gets written to a log file.

There are of course other ways to do this with the app.config, but this is
just a simple approach. and you can sort by filetime.

HTH,

CJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top