CLS 兼容问题
我定义了以下属性。 MyLibrary.PumpSignal 是一个枚举,如下所示:
Public Enum PumpSignal As Integer
PumpOff = 0
PumpOn = 1
End Enum
然后我有另一个具有 PumpSignal 类型属性的类。
Property PumpState() As MyLibrary.PumpSignal
Get
Return m_PumpState
End Get
Set(ByVal value As MyLibrary.PumpSignal)
m_PumpState = value
End Set
End Property
.NET 不断抱怨 PumpState 的返回值不符合 cls 标准。
I have the following property defined. MyLibrary.PumpSignal is an enum as follows:
Public Enum PumpSignal As Integer
PumpOff = 0
PumpOn = 1
End Enum
Then I have another class with a property of the PumpSignal type.
Property PumpState() As MyLibrary.PumpSignal
Get
Return m_PumpState
End Get
Set(ByVal value As MyLibrary.PumpSignal)
m_PumpState = value
End Set
End Property
.NET keeps complaining that the Return value from PumpState is no cls-compliant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当类型或其程序集显式标记为符合 CLS 时,该类型才符合 CLS。
将
添加到库中。或者,将
添加到该属性。A type is only CLS-compliant if it or its assembly is explicitly marked as CLS-compliant.
Add
<Assembly: CLSCompliant(True)>
to the library.Alternatively, add
<CLSCompliant(False)>
to the property.