By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,384 Members | 845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,384 IT Pros & Developers. It's quick & easy.

This code hangs my application!

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Can you do a trace and identify the line it hangs on?

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:Ob*************@TK2MSFTNGP14.phx.gbl:
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


Nov 21 '05 #2

P: n/a
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

"scorpion53061" <ad***@nospamherekjmsolutions.com> skrev i meddelandet
news:eQ****************@TK2MSFTNGP14.phx.gbl...
Can you do a trace and identify the line it hangs on?

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:Ob*************@TK2MSFTNGP14.phx.gbl:
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

Nov 21 '05 #3

P: n/a
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
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
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

"scorpion53061" <ad***@nospamherekjmsolutions.com> skrev i meddelandet
news:eQ****************@TK2MSFTNGP14.phx.gbl...
Can you do a trace and identify the line it hangs on?

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:Ob*************@TK2MSFTNGP14.phx.gbl:
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


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.