gem56
asked on
Enumeration error in interface module
Hi guys,
I've declared a Public enumeration (called MyRole) in a standard module and I can use it without any problems in all my class modules except in an interface module.
I get the following error message "'MyRole' cannot expose type 'GlobalDeclarations.MyRole ' outside the project through interface 'MyInterface'". I can get around it by using String or Integer for example but I'd really like to use the enumeration, for obvious reasons.
Is there any way around it?
/Michael
'---GlobalDeclarations module
Public Enum MyRole As Short
Tender = 0
Variation = 1
End Enum
'---Class X module
Friend ReadOnly Property Role() As String Implements VarIF.MyRole
.......
End Property
'---VarIF interface module (that gives an error)
ReadOnly Property Role() As MyRole
I've declared a Public enumeration (called MyRole) in a standard module and I can use it without any problems in all my class modules except in an interface module.
I get the following error message "'MyRole' cannot expose type 'GlobalDeclarations.MyRole
Is there any way around it?
/Michael
'---GlobalDeclarations module
Public Enum MyRole As Short
Tender = 0
Variation = 1
End Enum
'---Class X module
Friend ReadOnly Property Role() As String Implements VarIF.MyRole
.......
End Property
'---VarIF interface module (that gives an error)
ReadOnly Property Role() As MyRole
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To my current knowledge, no.
This is probably because the interface does not want any external dependencies. If what you were initially trying was allowed, then you would have to somehow bind your global module along with the interface. However by not specifying the return type of Role in the interface, I accomplished what you may want:
Public Interface Interface1
ReadOnly Property Role()
End Interface
Module Module1
Public Enum MyRole As Short
Tender = 0
Variation = 1
End Enum
End Module
Public Class Class1
Implements Interface1
Dim r As Module1.MyRole = MyRole.Tender
Public ReadOnly Property Role() Implements Interface1.Role
Get
Return r
End Get
End Property
End Class
This is probably because the interface does not want any external dependencies. If what you were initially trying was allowed, then you would have to somehow bind your global module along with the interface. However by not specifying the return type of Role in the interface, I accomplished what you may want:
Public Interface Interface1
ReadOnly Property Role()
End Interface
Module Module1
Public Enum MyRole As Short
Tender = 0
Variation = 1
End Enum
End Module
Public Class Class1
Implements Interface1
Dim r As Module1.MyRole = MyRole.Tender
Public ReadOnly Property Role() Implements Interface1.Role
Get
Return r
End Get
End Property
End Class
ASKER
Thanks a lot for your earlier solution doraiswamy and your explanation.
/Micael
/Micael
ASKER
Just for future reference, is there no way of using an externally defined enumerations in an interface.
I ask that because it worked out OK this time but in future it may not be possible to relocate the declaration to the interface.
/Michael