1 Replies - 3545 Views - Last Post: 10 August 2010 - 11:02 AM Rate Topic: -----

#1 25jordy256  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 10-August 10

'Catch' cannot catch type 'Object' because it is not &

Posted 10 August 2010 - 10:19 AM

Hi, I have another error in my code I don't know were I went wrong someone was nice enough to help me the with my last post :) now I only have 2 errors left of the same kind. I'm getting 'Catch' cannot catch type 'Object' because it is not 'System.Exception' or a class that inherits from 'System.Exception'. and 'Expression detected' My code looks right but maybe not anyone know the problem? thanks

Code underlined in blue: Catch obj1 As Object When (?)

Private Sub OpenJAMem()
            Dim num3 As Integer
            Try
                Dim num As Integer
                Dim num4 As Integer
Label_0000:
                num4 = 1
                Me.GetHandle.GetHandles()
Label_000D:
                num4 = 2
                If (Me.GetHandle.hWndJA = 0) Then
                    GoTo Label_00D3
                End If
Label_0022:
                ProjectData.ClearProjectError()
                Dim num2 As Integer = -2
Label_002A:
                num4 = 6
                JAMemory.GetWindowThreadProcessId(System.IntPtr.op_Explicit(Me.GetHandle.hWndJA), (num))
Label_0044:
                num4 = 7
                SharedValues.MemHandle = System.IntPtr.op_Explicit(JAMemory.OpenProcess(&H1F0FFF, 0, num))
                GoTo Label_00D3
Label_005E:
                num3 = 0
                Select Case (num3 + 1)
                    Case 1
                        GoTo Label_0000
                    Case 2
                        GoTo Label_000D
                    Case 3, 8
                        GoTo Label_00D3
                    Case 4, 5
                        GoTo Label_0022
                    Case 6
                        GoTo Label_002A
                    Case 7
                        GoTo Label_0044
                    Case Else
                        GoTo Label_00C8
                End Select
Label_008E:
                num3 = num4
                Select Case If((num2 > -2), num2, 1)
                    Case 0
                        GoTo Label_00C8
                    Case 1
                        GoTo Label_005E
                End Select
            Catch obj1 As Object When (?)
                ProjectData.SetProjectError(DirectCast(obj1, Exception))
                GoTo Label_008E
            End Try
Label_00C8:
            Throw ProjectData.CreateProjectError(-2146828237)
Label_00D3:
            If (num3 <> 0) Then
                ProjectData.ClearProjectError()
            End If
        End Sub

This post has been edited by 25jordy256: 10 August 2010 - 10:24 AM


Is This A Good Question/Topic? 0
  • +

Replies To: 'Catch' cannot catch type 'Object' because it is not &

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9580
  • View blog
  • Posts: 36,300
  • Joined: 12-June 08

Re: 'Catch' cannot catch type 'Object' because it is not &

Posted 10 August 2010 - 11:02 AM

Regarding 'cannot catch exception of type object'.. well it says it all there. Try/Catches only work with class exception objects.

replace: "Catch obj1 As Object When (?)" with the catch here:

Try
'-- code
Catch ex As Exception
'-- code to do when exception thrown.
End Try


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1