I am trying to use the exception class as coded below to create a new exception with a specific error number, I thought reading the descriptor of HRESULT that I would be able to set the value using a '=', however it throws an error when I do this. My next step was to implement a partial class that overloads the property for HRESULT, however I obviously either did that wrong, or am trying to use the partial class in a way that it is not meant to. So, How can I Set a custom Exception, with a custom error number in VB.net?
Dim ex As New Exception("Error message!")
ex.HResult = Int(10001981)
Partial Class exception
Public Overloads Property HRESULT As Integer
Set(value As Integer)
hresult_holder = value