4

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.

1
  • Please provide enough code so others can better understand or reproduce the problem. Commented Sep 21, 2021 at 17:09

1 Answer 1

8

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) .

Sign up to request clarification or add additional context in comments.

2 Comments

That makes since, What wasn't obvious to me was that the .razor file inherits something by default and that is ComponentBase. so by default having @inherits ComponentBase isn't needed because that is the default but when you change the code behind inheritance then there is a conflict.
Exactly. [filler filler]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.