You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Blazor WebAssembly中“Partial declarations must not specify different base classes”错误排查咨询

Blazor WebAssembly中“Partial declarations must not specify different base classes”错误排查咨询

我已经把能找到的相关问题都翻遍了,可还是没找到解决办法,来这里求助大家!

我现在有两个文件:Table.razor 和 Table.razor.cs,先给大家贴一下代码:

Table.razor 代码

@namespace MyComponents
@inherits Table<T>

@typeparam T where T : class
...

Table.razor.cs 代码

using Microsoft.AspNetCore.Components;

namespace MyComponents;

public partial class Table<T> : ComponentBase where T : class;

现在遇到的问题是,编译器直接抛出了这个错误:

Partial declarations of 'Table<T>' must not specify different base classes

我实在搞不懂为什么会报这个错,看起来两边的基类应该是一致的啊?

另外还附带一个“找不到相关dll”的错误,这两个问题会不会有关联?

更奇怪的是,我有另一组结构几乎一样的组件TableColumn,却完全没有报错,给大家做个对比参考:

TableColumn.razor 代码

@namespace MyComponents
@inherits TableColumn<T, TValue>

@typeparam T where T : class
@typeparam TValue

TableColumn.razor.cs 代码

public partial class TableColumn<T, TValue> : ComponentBase, ITableColumn
where T : class

这里的ITableColumn是一个空接口。

备注:内容来源于stack exchange,提问作者IchBinAb4los

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 11:28:50