0

I need to pass a custom exception class via .Net remoting but I am getting the error:

Type 'MyDll.Security.InvalidHashException' in Assembly 'MyDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.'

The InvalidHashException class is as follows:

Public Class InvalidHashException
    Inherits Exception

    Public Sub New()
    End Sub

    Public Sub New(ByVal message As String)
        MyBase.New(message)
    End Sub

    Public Sub New(ByVal message As String, ByVal inner As Exception)
        MyBase.New(message, inner)
    End Sub
End Class

I understand that I have to add the <Serializable()> attribute to the class but then I get the following error:

System.Runtime.Serialization.SerializationException: 'The constructor to deserialize an object of type 'MyDll.Security.InvalidHashException' was not found.'

Can someone please help with how I would add a constructor that would help deserialize this object.

Many thanks.

altwood
  • 101
  • 1
  • 8
  • 1
    https://stackoverflow.com/questions/94488/what-is-the-correct-way-to-make-a-custom-net-exception-serializable – dr.null May 24 '22 at 17:06
  • 1
    Ah yes, thanks a lot. Not sure why I didn't find that when I did my own search. – altwood May 25 '22 at 14:24

0 Answers0