anwarmir
asked on
An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll
Hi can u help me please i get the following error msg:
An unhandled exception of type 'System.NullReferenceExcep tion' occurred in system.windows.forms.dll
when the follwoing code is executed : Catch When Not System.Diagnostics.Debugge r.IsAttach ed
Can anybody help ????
#If DEBUG Then
Catch When Not System.Diagnostics.Debugge r.IsAttach ed
#Else
catch
#End If
'Just re-throw here, exception handled by BaseApplication
Throw
Finally
'Log end of application
BaseApplication.goError.Lo g("SESSION FINISHED", [Error].SeverityLevel.Info rmation)
'Stop base application
BaseApplication.Stop()
End Try
Else
An unhandled exception of type 'System.NullReferenceExcep
when the follwoing code is executed : Catch When Not System.Diagnostics.Debugge
Can anybody help ????
#If DEBUG Then
Catch When Not System.Diagnostics.Debugge
#Else
catch
#End If
'Just re-throw here, exception handled by BaseApplication
Throw
Finally
'Log end of application
BaseApplication.goError.Lo
'Stop base application
BaseApplication.Stop()
End Try
Else
This is the resulting call from the framework (pretty simple):
<MethodImpl(MethodImplOpti ons.Intern alCall)> _
Private Shared Function IsDebuggerAttached() As Boolean
End Function
Bob
<MethodImpl(MethodImplOpti
Private Shared Function IsDebuggerAttached() As Boolean
End Function
Bob
ASKER
Sorry But i a have just started VB.net...can someone explain a bit further.
Any tips on how i can resolve the problem.
Any tips on how i can resolve the problem.
What are you trying to do?
Bob
Bob
ASKER
I have started supporting a new system the code has already benn written.
It appears that the exception is being thrown by the following function, on the first line of the code:
obj Is Nothing Or Not Me.GetType Is obj.GetType
Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean
If obj Is Nothing Or Not Me.GetType Is obj.GetType Then
Return False
End If
Dim order As ViewedOrder = CType(obj, ViewedOrder)
Return order.Id = Me.Id And order.Customer = Me.Customer
End Function
Is there any way i can put some saftey checks in the Function so that the exception is not thrown
Thanks
It appears that the exception is being thrown by the following function, on the first line of the code:
obj Is Nothing Or Not Me.GetType Is obj.GetType
Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean
If obj Is Nothing Or Not Me.GetType Is obj.GetType Then
Return False
End If
Dim order As ViewedOrder = CType(obj, ViewedOrder)
Return order.Id = Me.Id And order.Customer = Me.Customer
End Function
Is there any way i can put some saftey checks in the Function so that the exception is not thrown
Thanks
Why are you trying to avoid the exception? It could be possible to "hide" an exception that you need to see that way.
Bob
Bob
ASKER
The thing is the exception in this function appears to crash the whole application. Is there any way round this?
I know i am not giving you much to go on...but ia m still in the early days of struggling to understand the application.
Thanks
I know i am not giving you much to go on...but ia m still in the early days of struggling to understand the application.
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks....This seems to work.
Appreciate your help on this one.
Cheers
Appreciate your help on this one.
Cheers
Bob