PC Review


Reply
Thread Tools Rate Thread

This code hangs my application!

 
 
Lars Netzel
Guest
Posts: n/a
 
      25th Oct 2004
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


 
Reply With Quote
 
 
 
 
scorpion53061
Guest
Posts: n/a
 
      25th Oct 2004
Can you do a trace and identify the line it hangs on?

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:(E-Mail Removed):
> 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


 
Reply With Quote
 
Lars Netzel
Guest
Posts: n/a
 
      25th Oct 2004
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" <(E-Mail Removed)> skrev i meddelandet
news:eQ%(E-Mail Removed)...
> Can you do a trace and identify the line it hangs on?
>
> "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
> news:(E-Mail Removed):
> > 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

>



 
Reply With Quote
 
CJ Taylor
Guest
Posts: n/a
 
      25th Oct 2004
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:(E-Mail Removed)...
> 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" <(E-Mail Removed)> skrev i meddelandet
> news:eQ%(E-Mail Removed)...
> > Can you do a trace and identify the line it hangs on?
> >
> > "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
> > news:(E-Mail Removed):
> > > 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

> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
application.followhyperlink hangs Access application Charlie O'Neill Microsoft Access 3 13th Mar 2010 05:31 PM
copying application code only or code and application togheter to another mdb file thread Microsoft Access 4 9th Apr 2007 09:44 PM
This code hangs on connect() if connect hangs. how to make this so that if connect hangs i time out after 10 seconds. perhaps there is someway to do this with ioctlsocket and select? can anyone show how to do this? Daniel Microsoft Windows 2000 Networking 0 15th Feb 2005 01:37 AM
asp.net application hangs Loane Sharp Microsoft ASP .NET 5 11th Feb 2005 07:00 PM
Application Hangs Christian Westerlund Microsoft Dot NET Compact Framework 1 29th Aug 2004 07:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 PM.