Unhandle exception

G

Guest

Hi all,
I'm getting an error messagebox that displays for less than a second and
disappers. I found the line that causing this error, and enclosed in a try
block, but I'm not able to catch this error and hide it from user to see it.
(I wasn't either able to see the error through Console.WriteLine). This
message has three buttons: Details, Quit, and Continue. I cannot read the
message and not able to catch it. Is there a way to catch this error?So, the
user wouldn't see the error. The application runs after this message with no
problem, and doesn't crash.
Code:
MyDataGrid.DataSource = ds.Tables("Table1")
'ds(dataset )is populated and always has rows. MyDataGrid is a customized
data grid control. I don't have any problem when assigning DataSource
property of the data grid for the first time, but after adding, deleting
records and trying to refresh the data grid control this line causes the
error message to be displayed.
Thanks for your input.
Roy
 
A

Armin Zingler

Roy said:
Hi all,
I'm getting an error messagebox that displays for less than a second
and disappers. I found the line that causing this error, and
enclosed in a try block, but I'm not able to catch this error and
hide it from user to see it. (I wasn't either able to see the error
through Console.WriteLine). This message has three buttons: Details,
Quit, and Continue. I cannot read the message and not able to catch
it. Is there a way to catch this error?So, the user wouldn't see the
error. The application runs after this message with no problem, and
doesn't crash. Code:
MyDataGrid.DataSource = ds.Tables("Table1")
'ds(dataset )is populated and always has rows. MyDataGrid is a
customized data grid control. I don't have any problem when
assigning DataSource property of the data grid for the first time,
but after adding, deleting records and trying to refresh the data
grid control this line causes the error message to be displayed.
Thanks for your input.
Roy

Have you tried putting the whole thread's main procedure into a try-catch
block?

If you're startup object (in project properties) is sub main, put the code
in sub main in a try-catch block.

If the startup object is a Form, add the following code to the Form:

shared sub main
try
AddHandler Application.ThreadException, AddressOf OnThreadException
application.run(new form1)
catch ex as exception
stop
end try
end sub

Private Shared Sub OnThreadException( _
ByVal sender As Object, _
ByVal e As System.Threading.ThreadExceptionEventArgs)

stop

End Sub

Replace form1 by the class name of your startup form.

This is only an attempt. I'm also fighting with the problem of unhandable
exceptions (in timer.tick event handlers).

Can the exception be caught by one of the two handlers?

Armin
 
C

Cor Ligthert

Roy,

I have as well seen that Microsoft has used the try and catch block to
*handle* datagrids.

It gives in my opinion anoying behaviour, especially because you don't know
where it is done.

It is done as well by the IsDate and the IsNumeric, however there you see no
side effects.

Cor
 
G

Guest

Cor,

Since this error doesn't cause any issues, is there a way to catch the error
and hide it from the user.
Thanks again,

Roy
 
C

Cor Ligthert

Roy,

Have you set in your IDE while your program is loaded in DEBUG the Exception
behaviour while debugging. Debug->Exceptions

Than you can set on what Exceptions your program has to stop while
debugging. Maybe can you find it and place yourself something around it.

For the rest I would not know how I could help you in this.

Cor
 
G

Guest

Cor thanks again,
I know exactly what line is causing the problem, but I'm out of luck to
catch it with try block.
 

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

Similar Threads


Top