|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
exceptions/inner exceptionsusing the following code, i never get a message box showing the error, but the default error sound is produced (like there should be an accompanying messagebox). \\\\\\\\\\ Dim FI As FileInfo = _ My.Computer.FileSystem.GetFileInfo(txtSelectedDocument.Text) Try My.Computer.FileSystem.CopyDirectory(FI.DirectoryName, _ lblResultText.Text, _ Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, _ FileIO.UICancelOption.ThrowException) MsgBox("Update is complete.", MsgBoxStyle.Information, _ "Complete.") Catch ex As Exception MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ & ex.InnerException.ToString, MsgBoxStyle.Critical, _ "Failed.") End Try \\\\\\\\\\\ how can i get the message box to show up, and to show up with the error? thanks, lance Lance,
Did you try this one, http://msdn2.microsoft.com/en-us/library/xz2d9afk.aspx Not catching the exeption in your cancel parameter I hope this helps, Cor Show quoteHide quote "Lance" <nu***@business.com> schreef in bericht news:%23ioNvtBrGHA.1552@TK2MSFTNGP02.phx.gbl... > hi all, > using the following code, i never get a message box showing the error, but > the default error sound is produced (like there should be an accompanying > messagebox). > > \\\\\\\\\\ > Dim FI As FileInfo = _ > My.Computer.FileSystem.GetFileInfo(txtSelectedDocument.Text) > > Try > My.Computer.FileSystem.CopyDirectory(FI.DirectoryName, _ > lblResultText.Text, _ > Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, _ > FileIO.UICancelOption.ThrowException) > MsgBox("Update is complete.", MsgBoxStyle.Information, _ > "Complete.") > Catch ex As Exception > MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ > & ex.InnerException.ToString, MsgBoxStyle.Critical, _ > "Failed.") > End Try > \\\\\\\\\\\ > > how can i get the message box to show up, and to show up with the error? > thanks, > lance > i changed the line
Catch ex As Exception to Catch ex As OperationCanceledException but now when i press the cancel button on the copy directory dialog box, all i get is the exception helper saying that the TargetInvocationException was unhandled. i put a breakpoint at the "Catch....:" line to check it out. the excpetion helper appears after trying to execute the msgbox line. Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uRWBd6CrGHA.5108@TK2MSFTNGP05.phx.gbl... > Lance, > > Did you try this one, > > http://msdn2.microsoft.com/en-us/library/xz2d9afk.aspx > > Not catching the exeption in your cancel parameter > > I hope this helps, > > Cor > "Lance" <nu***@business.com> schreef in bericht > news:%23ioNvtBrGHA.1552@TK2MSFTNGP02.phx.gbl... >> hi all, >> using the following code, i never get a message box showing the error, but the default >> error sound is produced (like there should be an accompanying messagebox). >> >> \\\\\\\\\\ >> Dim FI As FileInfo = _ >> My.Computer.FileSystem.GetFileInfo(txtSelectedDocument.Text) >> >> Try >> My.Computer.FileSystem.CopyDirectory(FI.DirectoryName, _ >> lblResultText.Text, _ >> Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, _ >> FileIO.UICancelOption.ThrowException) >> MsgBox("Update is complete.", MsgBoxStyle.Information, _ >> "Complete.") >> Catch ex As Exception >> MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ >> & ex.InnerException.ToString, MsgBoxStyle.Critical, _ >> "Failed.") >> End Try >> \\\\\\\\\\\ >> >> how can i get the message box to show up, and to show up with the error? >> thanks, >> lance >> > > Cor,
I *want* to catch the cancel error, though. lance Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uRWBd6CrGHA.5108@TK2MSFTNGP05.phx.gbl... > Lance, > > Did you try this one, > > http://msdn2.microsoft.com/en-us/library/xz2d9afk.aspx > > Not catching the exeption in your cancel parameter > > I hope this helps, > > Cor > "Lance" <nu***@business.com> schreef in bericht > news:%23ioNvtBrGHA.1552@TK2MSFTNGP02.phx.gbl... >> hi all, >> using the following code, i never get a message box showing the error, but the default >> error sound is produced (like there should be an accompanying messagebox). >> >> \\\\\\\\\\ >> Dim FI As FileInfo = _ >> My.Computer.FileSystem.GetFileInfo(txtSelectedDocument.Text) >> >> Try >> My.Computer.FileSystem.CopyDirectory(FI.DirectoryName, _ >> lblResultText.Text, _ >> Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, _ >> FileIO.UICancelOption.ThrowException) >> MsgBox("Update is complete.", MsgBoxStyle.Information, _ >> "Complete.") >> Catch ex As Exception >> MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ >> & ex.InnerException.ToString, MsgBoxStyle.Critical, _ >> "Failed.") >> End Try >> \\\\\\\\\\\ >> >> how can i get the message box to show up, and to show up with the error? >> thanks, >> lance >> > > i'd like to be able to properly catch the cancellation of the directory copy, but still no
luck displaying the messagebox (i'm still just only getting the default error chime). any other suggestions would be greatly appreciated. when stepping through the code, it gets to the MsgBox line, and the never actually shows it. lance Show quoteHide quote "Lance" <nu***@business.com> wrote in message news:%23ioNvtBrGHA.1552@TK2MSFTNGP02.phx.gbl... > hi all, > using the following code, i never get a message box showing the error, but the default > error sound is produced (like there should be an accompanying messagebox). > > \\\\\\\\\\ > Dim FI As FileInfo = _ > My.Computer.FileSystem.GetFileInfo(txtSelectedDocument.Text) > > Try > My.Computer.FileSystem.CopyDirectory(FI.DirectoryName, _ > lblResultText.Text, _ > Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, _ > FileIO.UICancelOption.ThrowException) > MsgBox("Update is complete.", MsgBoxStyle.Information, _ > "Complete.") > Catch ex As Exception > MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ > & ex.InnerException.ToString, MsgBoxStyle.Critical, _ > "Failed.") > End Try > \\\\\\\\\\\ > > how can i get the message box to show up, and to show up with the error? > thanks, > lance > if i change the messagebox to debug.print then i get the appropriate message in the
immediate window: "A first chance exception of type 'System.OperationCanceledException' occurred in Microsoft.VisualBasic.dll The operation was canceled." but using a messagebox is causing problems (no box, just sound) lance Show quoteHide quote "Lance" <nu***@business.com> wrote in message news:uhb%23iLMrGHA.3992@TK2MSFTNGP04.phx.gbl... > i'd like to be able to properly catch the cancellation of the directory copy, but still > no luck displaying the messagebox (i'm still just only getting the default error chime). > any other suggestions would be greatly appreciated. > > when stepping through the code, it gets to the MsgBox line, and the never actually shows > it. > > lance > > "Lance" <nu***@business.com> wrote in message > news:%23ioNvtBrGHA.1552@TK2MSFTNGP02.phx.gbl... >> hi all, >> using the following code, i never get a message box showing the error, but the default >> error sound is produced (like there should be an accompanying messagebox). >> >> \\\\\\\\\\ >> Dim FI As FileInfo = _ >> My.Computer.FileSystem.GetFileInfo(txtSelectedDocument.Text) >> >> Try >> My.Computer.FileSystem.CopyDirectory(FI.DirectoryName, _ >> lblResultText.Text, _ >> Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, _ >> FileIO.UICancelOption.ThrowException) >> MsgBox("Update is complete.", MsgBoxStyle.Information, _ >> "Complete.") >> Catch ex As Exception >> MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ >> & ex.InnerException.ToString, MsgBoxStyle.Critical, _ >> "Failed.") >> End Try >> \\\\\\\\\\\ >> >> how can i get the message box to show up, and to show up with the error? >> thanks, >> lance >> > > Lance wrote:
> using the following code, i never get a message box showing the error Since you're catching Exception, you can't guarantee that the > Catch ex As Exception > MsgBox("Copying did not finish." & DoubleCrLf & "Error: " _ > & ex.InnerException.ToString, MsgBoxStyle.Critical, _ > "Failed.") InnerException property is going to have a value. If it arrives as a null reference, the code that calls "ex.InnerException.ToString" will fail. Only catch the type of Exception you want, or make sure that you've got a valid Inner Exception before displaying it, as in Catch ex As Exception If ex.InnerException Is Nothing Then MsgBox("Copying did not finish." & DoubleCrLf _ & "Error: " & ex.ToString() _ , MsgBoxStyle.Critical _ , "Failed." _ ) Else MsgBox("Copying did not finish." & DoubleCrLf _ & "Error: " & ex.InnerException.ToString() _ , MsgBoxStyle.Critical _ , "Failed." _ ) End If HTH, Phill W.
Menus from a database table and addhandler
Problem with two version of program in one code and class referenc Expose Count from System.Collections.CollectionBase in an inherited class Force Windows to "See" new files burned to a CD/DVD? Internet connection present? Obtain info from other computer controlling splash screen form SendMessage() Assembly info from separate project? Beginner VB.NET group? |
|||||||||||||||||||||||