覆盖抽象类方法:WinCE/.NetCF2.0 [英] Overiding an abstract class method: WinCE/.NetCF2.0

查看:58
本文介绍了覆盖抽象类方法:WinCE/.NetCF2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抽象类中定义的方法的重载与WindowsCE6应用程序(具有.Net2.0 CF)和Windows应用程序(具有.Net2.0完整框架)是否有所不同?

我在上述两个平台(使用VS2005中使用不同的项目模板)中编译相同的代码时遇到问题. Windows应用程序可以正常编译,没有任何错误,但是WinCE应用程序失败并显示以下错误:"no suitable method found to override".

我想念什么吗?

任何帮助表示赞赏.

提前谢谢.


[已编辑]"Pre"标记已从普通句子中删除[/已编辑]

Does the overriding of methods defined in an abstract class differ from a WindowsCE6 app (with .Net2.0 CF) and a Windows App (with .Net2.0 full framework)?

I am having an issue with compiling the same code in the above two platforms (using different project templates in VS2005). Windows app compiles fine without any error, but WinCE app fails with an error: "no suitable method found to override".

Am I missing something?

Any help is appreciated.

Thanks in advance.


"Pre" tags removed from normal Sentences[/Edited]

推荐答案

[添加到Kryukov的响应中.]

.NET CF与常规.NET版本有很大不同(就像WP7的SL与完整的Silverlight有所不同). CF版本有可能在基类中没有此特定方法(不足为奇,因为精简版通常比其完整版本薄得多).
[Adding to Kryukov''s response.]

.NET CF considerably differs from the regular .NET version (just as how SL for WP7 differs from full Silverlight). It''s possible that the CF version does not have this particular method in the base class (not surprising as compact editions are usually far thinner than their full equivalents).


OOP和C#的基础知识完全不依赖于平台.而是,您在某个地方搞砸了.如果使用不同的模板,则可以将其中一个项目放在一起,而缺少一些文件(带有父类的文件)或引用.

要对其进行整理,请显示代码片段,包括令人讨厌的代码片段和abstract所在的基类,编译错误所指向的确切行以及项目文件的文本.

在TSKNaidu发表评论后,代码为:

该问题在层次结构中的任何基类中均缺少"abstract bool MoveNode"或"virtual boon MoveNode".
您应该使用Visual Studio在两个平台上轻松检查这一事实.将光标放在MoveNode上并激活上下文菜单,选择转到定义",转到基类代码(可以从找到的元数据生成),然后向上到下一个基类,直到找到我想尝试重写的方法的抽象或虚拟声明.
This is the very basics of OOP and C#, does not depend on the platform at all. Rather, you''re messing up somewhere. If you''re using different template, you could put one of the projects together missing some file (the one with parent class) or a reference.

To sort it out, show fragments of code, both offending and a base class where abstract is, on what exactly line a compilation error points, and the text of your project files.

After a comment by TSKNaidu with the code:

The problem is missing "abstract bool MoveNode" or "virtual boon MoveNode" in any of the base classes up the hierarchy.
You should easily check up this fact on both platform using Visual Studio. Put a cursor on MoveNode and activate context menu, select "Go to Definition", go to base class code (it can be generated from meta-data, which is find), then up to the next base class until you find the abstract or virtual declaration of the method you try to override.


我怀疑问题出在类型System.Drawing.Point和System.Windows.Forms.MouseButtons的两个参数上.

我假设您按原样使用此图形库,也不要重新编译它.然后,它将继续使用常规框架的System.Drawing和System.Windows.Forms命名空间.当您为紧凑型框架编译代码时,它将保持这种方式.尽管名称空间和名称相同,但这些参数并不相同,重载也不起作用.

解决方案?我唯一能想到的就是为紧凑型框架获取此图形库,如果它确实存在的话.


我现在正在工作,无法快速检验我的理论,但是我很确定这就是这里发生的事情.

EditEdit:我已经找到了时间,并一起鞭打了几个测试班来确认我的理论.覆盖抽象方法时,我得到了完全相同的错误.该方法的参数来自两个不同的库,它们扮演不同的框架的角色.它们具有相同的名称空间,相同的名称和相同的实现.但是由于它们来自不同的框架,因此它们不被接受为同一类型,并且覆盖失败.
I suspect the problem to come from the two parameters of the types System.Drawing.Point and System.Windows.Forms.MouseButtons.

I assume you use this graphics library as it is and don''t recompile it as well. Then it will keep on using the System.Drawing and System.Windows.Forms namespaces of the regular framework. It stays that way when you compile your code for the compact framework. Despite identical namespaces and names, these parameters are not the same and the overload does not work.

The solution? The only thing I can think of is to get this graphics library for the compact framework, if it exists at all.


I''m at work right now and can''t quickly test my theory, but I''m quite sure that this is what happens here.

Edit I have found the time and whipped together a few test classes to confirm my theory. I got exactly the same error when overriding the abstract method. The params of the method came from two different libraries, playing the role of different frameworks. They had identical namespaces, identical names and identical implementations. But since they came from different frameworks, they were not accepted as the same type and the override failed.,


这篇关于覆盖抽象类方法:WinCE/.NetCF2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆