H
Henrry Pires
Hello to all.
I have and strange and complicated problem.
My asp.net application raise errors when the data that the user input is
invalid. For example: The user didn't fill all some data (customer name or
SSN and so on). I have a class that try to validate the data and is
something is wrong it raises an error. That error is a class that I made,
this class inherits from System.Exceptio. So far so good.
It works fine, but only in 2 classes it doesn't work. I fire my error when
the data isn't correct but in the webpage the error is an
System.Reflection.TargetInvocationException that has as a inner exception
the error that I fire.
I will put some code to make it clear
WEB FORM
Private sub SaveData()
Declare BRL as NEW Customer
'Fill the brl object
With BRL
.Name = txtName.Text
.SSN = txtSSN.Text
...
End With
Try
BRL.CheckSaveRules
BRL.Save
Catch ex As ValidationRowException
'Display an alert message to the user
ShowMessage(ex.Message, Page_MessageBox.MsgType.CriticalInformation)
Catch ex As System.Reflection.TargetInvocationException
'this catch it wasn't suppose to exist.
'This is the error that the web form catch and I don't know why.
Catch ex As Exception
ShowUnKnowError
Finally
BRL.Dispose()
End Try
End sub
BRL
Public sub CheckSaveRules
'Creates an instance of the validator object and get the not null fields of
this dataTable
Dim validation As New RecordCommonValidation(GetRequiredFields)
'Gets a row with all the data to be validated
Dim row As DataRow = FillTableOP()
'Calls the validate method of the Validation Class
validation.Validate(row)¨
'Some other validations
....
End sub
FramekWork Validation Class
Public Sub Validate(ByVal RowToValidate As DataRow)
'Check each cell of the row and if any of the are null (and it wasn't
suppose to be null) raises the error
Throw New ValidationRowException(Enums.RowFailType.NotField,
Consts.NotFillMessage)
...
End sub
It is a long post I know but I don't know what else I can try to resolve
this strange thing.
I have and strange and complicated problem.
My asp.net application raise errors when the data that the user input is
invalid. For example: The user didn't fill all some data (customer name or
SSN and so on). I have a class that try to validate the data and is
something is wrong it raises an error. That error is a class that I made,
this class inherits from System.Exceptio. So far so good.
It works fine, but only in 2 classes it doesn't work. I fire my error when
the data isn't correct but in the webpage the error is an
System.Reflection.TargetInvocationException that has as a inner exception
the error that I fire.
I will put some code to make it clear
WEB FORM
Private sub SaveData()
Declare BRL as NEW Customer
'Fill the brl object
With BRL
.Name = txtName.Text
.SSN = txtSSN.Text
...
End With
Try
BRL.CheckSaveRules
BRL.Save
Catch ex As ValidationRowException
'Display an alert message to the user
ShowMessage(ex.Message, Page_MessageBox.MsgType.CriticalInformation)
Catch ex As System.Reflection.TargetInvocationException
'this catch it wasn't suppose to exist.
'This is the error that the web form catch and I don't know why.
Catch ex As Exception
ShowUnKnowError
Finally
BRL.Dispose()
End Try
End sub
BRL
Public sub CheckSaveRules
'Creates an instance of the validator object and get the not null fields of
this dataTable
Dim validation As New RecordCommonValidation(GetRequiredFields)
'Gets a row with all the data to be validated
Dim row As DataRow = FillTableOP()
'Calls the validate method of the Validation Class
validation.Validate(row)¨
'Some other validations
....
End sub
FramekWork Validation Class
Public Sub Validate(ByVal RowToValidate As DataRow)
'Check each cell of the row and if any of the are null (and it wasn't
suppose to be null) raises the error
Throw New ValidationRowException(Enums.RowFailType.NotField,
Consts.NotFillMessage)
...
End sub
It is a long post I know but I don't know what else I can try to resolve
this strange thing.