Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inherited base class that inherits ComponentBase in partial class gives error

I am working with a something.razor file and a code behind Something.razor.cs file. My partial class inherits from SomethingBase which itself inherits from ComponentBase.

This however gives errors

CS0115 .buildrendertree(rendertreebuilder)': no suitable method found to override in partial class CS0263 partial declarations of must not specify different base classes.

However if Something inherits directly from ComponentBase there is no issue.

First question please be gentle. I'll update with code and more detail in the morning if needed.

like image 707
Power5000 Avatar asked Oct 12 '25 10:10

Power5000


1 Answers

With a code behind file you have 2 spots where you can specify the base class.

You will always have to specify it in the .razor file because you don't want the default there:

// Something.razor
@inherits SomethingBase 

and then you have a choice in the .razor.cs file:

// Something.razor.cs (a)
partial class Something      // take base class from other part
{
} 

or

// Something.razor.cs (b)
public partial class Something : SomethingBase  // must use the same as other part
{
} 

I would use (a) .

like image 85
Henk Holterman Avatar answered Oct 14 '25 23:10

Henk Holterman