热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

部分声明不得指定不同的基类-Partialdeclarationsofmustnotspecifydifferentbaseclasses

IknowthereisinformationonthisontheinternetbutImhavingproblemstranslatingittomysitu

I know there is information on this on the internet but Im having problems translating it to my situation.

我知道在互联网上有关于此的信息,但我在将其转换为我的情况时遇到了问题。

I have a xaml window and im getting the error: Partial declarations of 'GX3OpenStackupGUIPlugin.GX3OpenStackupGUIPlugin' must not specify different base classes .

我有一个xaml窗口,我得到错误:'GX3OpenStackupGUIPlugin.GX3OpenStackupGUIPlugin'的部分声明不能指定不同的基类。

My code behind is:

我的代码背后是:

public partial class GX3OpenStackupGUIPlugin : GX3ClientPlugin, IGX3PluginInterface
    {

My xaml is:

我的xaml是:


Please could someone advise :)

请有人建议:)

Here is a link to what I have found but am struggling to translate... Partial declarations must not specify different base classes

这是我找到的链接,但我正在努力翻译......部分声明不能指定不同的基类

After doing a little more research I have discovered that if I change my code behind to implement the top level element in my xaml it gets rid of the error. Thats obviously still a problem as my codebehind class needs to implement the interfaces I have designed.

在做了一点研究之后,我发现如果我改变我的代码来实现我的xaml中的顶级元素,它就会摆脱错误。这显然仍然是一个问题,因为我的代码隐藏类需要实现我设计的接口。

4 个解决方案

#2


4  

I got this error when I tried to inherit a TabItem. The .cs looked like:

当我尝试继承TabItem时出现此错误。 .cs看起来像:

public partial class ucTabItemSelectionCriteria : TabItem

The first line of XAML looked like:

XAML的第一行看起来像:

That was the mismatch that would show up when code was generated from the XAML. It was fixed when I change the first 2 lines of XAML to:

这是从XAML生成代码时出现的不匹配。当我将XAML的前两行更改为:

    

Now both are inherited from the TabItem control.

现在两者都继承自TabItem控件。

#3


2  

Partial class declarations mean you can specify code for the same class in 2 different files:

部分类声明意味着您可以在2个不同的文件中指定同一个类的代码:

AOther.cs

public partial class A
{}

A.cs

public partial class A
{}

This error is telling you that the classes define different bases.

此错误告诉您类定义了不同的基础。

AOther.cs

public partial class A : B
{}

A.cs

public partial class A : X
{}

In the example, A can not inherit from B and X in different files. I think it's possible to specify the inheritance chain in XAML but I can't see anything doing this in your posted code.

在示例中,A不能从不同文件中的B和X继承。我认为可以在XAML中指定继承链,但我在发布的代码中看不到任何这样做。

Update

With the modifications to the question in the comment I suggest the following. Rather than looking at inheritance to make your control/window inherit from a GX3ClientPlugin you should look at composition. Essentially this means, place an instance of a GX3ClientPlugin on your form and call through to it. If need be write an interface for the GX3ClientPlugin class, make the form implement it, but for each method just call through to the instance it holds underneath. I think inheritance is the wrong way to go with this problem, as your class has 2 concerns - UI and GX3ClientPlugin logic.

随着评论中对问题的修改,我建议如下。而不是查看继承以使您的控件/窗口继承自GX3ClientPlugin,您应该查看组合。基本上这意味着,在表单上放置一个GX3ClientPlugin实例并调用它。如果需要为GX3ClientPlugin类编写一个接口,请使表单实现它,但是对于每个方法,只需调用它所在的实例。我认为继承是解决这个问题的错误方法,因为你的类有两个问题 - UI和GX3ClientPlugin逻辑。

#4


1  

There are going to be two (or more) parts to that partial class. If you search, you should find another class GX3OpenStackupGUIPlugin, that probably specifies something like Control as the base-type. You are only looking at one part of the file. The other half probably needs to be expanded from under the xaml.

该部分类将有两个(或更多)部分。如果你搜索,你应该找到另一个类GX3OpenStackupGUIPlugin,它可能指定像Control这样的基类型。您只看到文件的一部分。另一半可能需要从xaml下扩展。

The problem is that two files are doing something like this:

问题是两个文件正在做这样的事情:

(file the first)

(档案第一)

public partial class GX3OpenStackupGUIPlugin : GX3ClientPlugin, IGX3PluginInterface {}

(file the second)

(档案第二)

public partial class GX3OpenStackupGUIPlugin : SomethingElse {...}

推荐阅读
  • 图像因存在错误而无法显示 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
  • vue使用
    关键词: ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文介绍了通过ABAP开发往外网发邮件的需求,并提供了配置和代码整理的资料。其中包括了配置SAP邮件服务器的步骤和ABAP写发送邮件代码的过程。通过RZ10配置参数和icm/server_port_1的设定,可以实现向Sap User和外部邮件发送邮件的功能。希望对需要的开发人员有帮助。摘要长度:184字。 ... [详细]
  • 关键词:Golang, Cookie, 跟踪位置, net/http/cookiejar, package main, golang.org/x/net/publicsuffix, io/ioutil, log, net/http, net/http/cookiejar ... [详细]
  • 怎么在PHP项目中实现一个HTTP断点续传功能发布时间:2021-01-1916:26:06来源:亿速云阅读:96作者:Le ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • Windows7 64位系统安装PLSQL Developer的步骤和注意事项
    本文介绍了在Windows7 64位系统上安装PLSQL Developer的步骤和注意事项。首先下载并安装PLSQL Developer,注意不要安装在默认目录下。然后下载Windows 32位的oracle instant client,并解压到指定路径。最后,按照自己的喜好对解压后的文件进行命名和压缩。 ... [详细]
  • 本文讨论了如何使用Web.Config进行自定义配置节的配置转换。作者提到,他将msbuild设置为详细模式,但转换却忽略了带有替换转换的自定义部分的存在。 ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • 本文介绍了关系型数据库和NoSQL数据库的概念和特点,列举了主流的关系型数据库和NoSQL数据库,同时描述了它们在新闻、电商抢购信息和微博热点信息等场景中的应用。此外,还提供了MySQL配置文件的相关内容。 ... [详细]
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
  • 本文介绍了使用C++Builder实现获取USB优盘序列号的方法,包括相关的代码和说明。通过该方法,可以获取指定盘符的USB优盘序列号,并将其存放在缓冲中。该方法可以在Windows系统中有效地获取USB优盘序列号,并且适用于C++Builder开发环境。 ... [详细]
  • Summarize function is doing alignment without timezone ?
    Hi.Imtryingtogetsummarizefrom00:00otfirstdayofthismonthametric, ... [详细]
author-avatar
zaizaiwaipo
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有