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)errors()
Partial Class exception Inherits System.Exception Dim hresult_holder Public Overloads Property HRESULT As Integer Get Return hresult_holder End Get Set(value As Integer) hresult_holder = value End Set End PropertyEnd Class