Modify your constructor to the following so that it calls the base class constructor properly:
public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}
Note that a constructor is not something that you can call anytime within a method. That’s the reason you’re getting errors in your call in the constructor body.
Related Contents:
- Why not inherit from List?
- What’s the difference between an object initializer and a constructor?
- How to inherit constructors?
- C# constructor execution order
- C# Error: Parent does not contain a constructor that takes 0 arguments
- Is there an alternative to bastard injection? (AKA poor man’s injection via default constructor)
- Inheritance with base class constructor with parameters [duplicate]
- How do I check if a type provides a parameterless constructor?
- base() and this() constructors best practices
- DataContractSerializer doesn’t call my constructor?
- Is it important to unit test a constructor?
- What’s the correct alternative to static method inheritance?
- C#’s equivalent of Java’s
- When is a custom attribute’s constructor run?
- Get all derived types of a type
- Why does this polymorphic C# code print what it does?
- Why can’t I create an abstract constructor on an abstract C# class?
- Why should constructors on abstract classes be protected, not public?
- For an object, can I get all its subclasses using reflection or other ways?
- Abstract constructor in C# [duplicate]
- C# – Making all derived classes call the base class constructor
- In C#, do you need to call the base constructor?
- Checking if Type or instance implements IEnumerable regardless of Type T
- Is there any way to call the parent version of an overridden method? (C# .NET)
- Extension methods versus inheritance
- is it possible to mark overridden method as final
- Initializing a Generic.List in C#
- Enum “Inheritance”
- Merge two (or more) lists into one, in C# .NET
- How do I get a human-readable file size in bytes abbreviation using .NET?
- Entity Framework – Code First – Can’t Store List
- How can I get a list of users from active directory?
- Does anyone still use [goto] in C# and if so why? [closed]
- What’s the difference between Application.ThreadException and AppDomain.CurrentDomain.UnhandledException?
- Opposite of String.Split with separators (.net)
- What is WCF RIA services?
- C# equivalent to Java’s Exception.printStackTrace()?
- How can I get all classes within a namespace?
- What’s the difference between the new netstandardapp and netcoreapp TFMs?
- Avoiding first chance exception messages when the exception is safely handled
- Settings variable values in a Moq Callback() call
- Why method overloading is not allowed in WCF?
- Convert SQL to Linq left join with null
- How to extract custom header value?
- cannot implicitly convert type ‘bool?’ to ‘bool’. An explicit conversion exists (are you missing a cast?)
- Show row number in row header of a DataGridView
- Confusion regarding threads and if asynchronous methods are truly asynchronous in C#
- Intersection of two string array (ignore case)
- How can I customize the system menu of a Windows Form?
- How do I set a readonly field in an initialize method that gets called from the constructor?