After some research I found that a custom exception should look like this:
using System;
using System.Runtime.Serialization;
namespace YourNamespaceHere
{
It will look something like this. You look for more details here What is the correct way to make a custom .NET Exception serializable?
[Serializable()]
public class YourCustomException : Exception, ISerializable
{
public Int Id { get; set; }
public Int ErrorCode { get; set; }
public YourCustomException() : base() { }
public YourCustomException(string message) : base(message) { }
public YourCustomException(string message, System.Exception inner) : base(message, inner) { }
public YourCustomException(SerializationInfo info, StreamingContext context) : base(info, context) { }
public YourCustomException(string message, int Id, int ErrorCode)
: base(message)
{
this.Id = Id;
this.ErrorCode = ErrorCode;
}
}