Answer the question
In order to leave comments, you need to log in
No constructor defined for type 'TypeName' when class is overridden?
I can't figure out what the problem is. I'm new to C# and have never encountered this problem before.
Google answers are also off topic.
In general, when trying to inherit a certain class, it displays such a message. The class itself is inside a third party compiled assembly.
I looked at the assembly using Reflector, it is clear that the constructor has the visibility modifier internal.
The internal keyword is an access modifier for types and type members. Internal types or members are only accessible inside files in the same assembly
Answer the question
In order to leave comments, you need to log in
You can if you add the InternalsVisibleTo attribute in the source assembly in the manifest . How to add such an attribute to the compiled assembly is a separate topic.
This is also used in assembly testing so that separate tests in separate assemblies can access internal classes that are also subject to testing.
MSDN makes it clear that you cannot access these classes, let alone inherit from them.
As stated above, it is not possible. But if you really want to, then you can . But it's better not to do that.
If internal is the class itself, then it is impossible in any way.
If internal is the default constructor and there are no other public constructors, then it is also impossible.
If there is a public constructor with parameters, and you want to define a default one (without parameters) in your class, then you need to do something like this:
let's say the parent class constructor is like this:
public A(int param)
{
}
public B() : base(0)
{
}
public B(int a): base(a)
{
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question