Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:19:48+00:00 2026-06-18T16:19:48+00:00

I’ve been trying to write my own custom constructor, but getting error about base()

  • 0

I’ve been trying to write my own custom constructor, but getting error about base() constructor. I’ve also been searching how to solve this error, but found nothing and all the examples round the internet are showing almost the same code as mine.

Whole Exception.cs content:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RegisService
{
public class Exceptions : Exception
{        
}

  public class ProccessIsNotStarted : Exceptions
  {
      ProccessIsNotStarted()
          : base()
      {
          //var message = "Formavimo procesas nestartuotas";
          //base(message);
      }

      ProccessIsNotStarted(string message) 
          : base(message) {}

      ProccessIsNotStarted(string message, Exception e)
          : base(message, e) {}
  }
}

first overload with base() is working, no errors were thrown. Second and the third
overloads are telling me that :

“RegisService.Exceptions does not contain a constructor that takes
1(2) arguments”

One more way I’ve been trying to solve the error:

ProccessIsNotStarted(string message)              
    {
        base(message);
    }

    ProccessIsNotStarted(string message, Exception e)
    {
        base(message, e);
    }

this time, VS is telling me that:

“Use of keyword ‘base’ is not valid in this context”

So, where is the problem? Looks like the base() constructor has some weird overloads or I’m calling it in inappropriate way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:19:50+00:00Added an answer on June 18, 2026 at 4:19 pm

    Your Exceptions class needs to define all constructors you want to provide. The constructors of System.Exception are not virtual or abstract. The keyword base does not call the members of all base classes, but of the one base class you provide in the class declaration. Take a look at this:

    public class Exceptions : Exception
    {
        public Exceptions(string message)
            : base(message) {}
    }
    
    public class ProccessIsNotStarted : Exceptions
    {
        public ProccessIsNotStarted()
            : base()
        {
        }
    
        public ProccessIsNotStarted(string message) 
            : base(message)
        {
            // This will work, because Exceptions defines a constructor accepting a string.
        }
    
        public ProccessIsNotStarted(string message, Exception e)
            : base(message, e) 
        {
            // This will not work, because Exceptions does not define a constructor with (string, Exception).
        }
    }
    

    The parameterless constructor gets defined by default. To hide it you need to declare it private.

    Regarding to the MSDN you should keep your exception inheritance hierarchy flat:

    If you are designing an application that needs to create its own exceptions, you are advised to derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value.

    You might also take a look at this page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.