Error "'Object' does not contain a constructor that takes 1 Arguments"

Asked

Viewed 474 times

1

I wonder why this mistake is happening.

I created one class that extends another, but when I call her builder (parent class) it makes an error.

Ali says that there is no constructor with 1 parameter, but as you can see in the second image, there is yes.

subclasse

superclasse

  • Probably the class you’re trying to inherit hasn’t been recognized... Tries to rename the class you are creating or check if any reference or using inclusion is missing from the used namespaces.

  • Would be appearing error in it, and I could not see the "definition" of it (Peek Definition), already imported everything straight.

2 answers

4


In your code:

class MySQLConnection : MySqlConnection

In the code of the superclass:

public sealed class MySqlConnection : DbConnection, IDisposable, ICloneable

Basically, you shouldn’t inherit from MySqlConnection. There’s no reason to do that and that sealed in the class declaration says that it is forbidden to inherit from it.

I don’t know what you’re trying to do, but whatever it is, you shouldn’t try to inherit from MySqlConnection.

Also, having two classes whose name only differs in upper/lower case is a bad programming practice as it is very confusing.

  • Ah, of course, I hadn’t even noticed that modifier there, vlw.

-1

Try doing a different method:

public MySQLConnection(MySQLData data, MySQLUser user)
{
     base("meh");
} /* ou */
public MySQLConnection(MySQLData data, MySQLUser user)

If you can’t, access this link.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.