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

Unhandle exception

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

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Roy" <Ro*@discussions.microsoft.com> schrieb
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

Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

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

"Cor Ligthert" wrote:
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

Nov 21 '05 #4

P: n/a
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
Nov 21 '05 #5

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

"Cor Ligthert" wrote:
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

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.