【问题标题】:'Property' cannot implement 'Property' because there is no matching property on interface 'IName'“属性”无法实现“属性”,因为接口“IName”上没有匹配的属性
【发布时间】:2012-01-16 09:59:14
【问题描述】:

我现在在接口方面遇到了一些非常奇怪的问题。

我有一个非常简单的设置。

在我的一个班级中,我有一个 PropertyInterface 实现 Property

在我的课堂上是这样的:

Private _oForm As IForm
Public Property Form As IForm Implements IContainer.Form
    Set(value As IForm)
        Me._oForm = value
    End Set
    Get
        Return Me._oForm
    End Get
End Property

这是 IContainer 接口:

Public Interface IContainer

    Property Form As IForm

    Sub OpenScreen(p_oDataKey As DataKey, Optional ByVal p_oOpenScreenProperties As OpenScreenProperties = Nothing)

End Interface

这很简单,不是吗?根本没有复杂的实现,我好像也搞不定。

为了它,现在我的 IForm 里面什么都没有:

Public Interface IForm

End Interface

我总是得到:

Error   2   Class 'BaseContainer' must implement 'Property Form As IForm' for interface 'Common.IContainer'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.

Error   3   'Form' cannot implement 'Form' because there is no matching property on interface 'Common.IContainer'.

在我的整个项目中,我喜欢有几十个这样的界面,我不敢相信这个简单的界面不能工作!请在这里帮我一把:P

非常感谢!

【问题讨论】:

  • 更新你的代码 sn-ps 以显示一个名为“BaseContainer”的类

标签: .net vb.net interface


【解决方案1】:

检查以确保没有在类的其他地方添加另一个实现 icontainer.form 或实现 iform.form。

例如,如果您键入Implements IContainer,VB 将有助于将实现器添加到您的类中。如果稍后更改接口,您可能会有剩余的引用。

【讨论】:

    猜你喜欢
    • 2016-01-28
    • 1970-01-01
    • 2015-03-29
    • 2011-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    相关资源
    最近更新 更多