compile error after defining custom attribute

  • Thread starter Thread starter Harry F. Harrison
  • Start date Start date
H

Harry F. Harrison

I get 2 compile errors on assembly attributes after creating a custom
attribute. If I comment out the attribute, the errors go away. I don't get
it because my attribute specifies class usage, not assembly usage.

Assembly attribute 'System.Runtime.InteropServices.GuidAttribute' is not
valid: Assembly custom attribute
'System.Runtime.InteropServices.GuidAttribute' was specified multiple times
with different values

Attribute 'System.CLSCompliantAttribute' cannot be specified more than once
in this project, even with identical parameter values.

Here is the definition of the custom attribute I created:

<System.AttributeUsage(System.AttributeTargets.Class, Inherited:=False,
AllowMultiple:=True)> _

Public Class ApplicationTypeAttribute

Inherits System.Attribute

Public Enum ApplicationPurposeAttributeEnum

BudgetAttributeEnum = 1

ConfigurationAttributeEnum = 2

MainMenuAttributeEnum = 3

ReportsAttributeEnum = 4

SecurityAttributeEnum = 5

End Enum

Private AttributeEnum As ApplicationPurposeAttributeEnum

Public Sub New(ByVal AppType As ApplicationPurposeAttributeEnum)

AttributeEnum = AppType

End Sub

Public ReadOnly Property IsConfiguration() As Boolean

Get

Return (AttributeEnum =
ApplicationPurposeAttributeEnum.ConfigurationAttributeEnum)

End Get

End Property

Public ReadOnly Property IsSecurity() As Boolean

Get

Return (AttributeEnum =
ApplicationPurposeAttributeEnum.SecurityAttributeEnum)

End Get

End Property

Public ReadOnly Property ApplicationAttribute() As
ApplicationPurposeAttributeEnum

Get

Return AttributeEnum

End Get

End Property

End Class
 
I've simplified the attribute class, and added full namespaces,etc., and
still get the compile errors...


<System.AttributeUsage(System.AttributeTargets.Class, Inherited:=False,
AllowMultiple:=True)> _

Public Class ApplicationTypeAttribute

Inherits System.Attribute

Public Enum ApplicationPurposeAttributeEnum

BudgetAttributeEnum = 1

ConfigurationAttributeEnum = 2

MainMenuAttributeEnum = 3

ReportsAttributeEnum = 4

SecurityAttributeEnum = 5

End Enum

Private AttributeEnum As
CECC.Financial2000.Global.Interfaces.ApplicationTypeAttribute.ApplicationPur
poseAttributeEnum

Public Sub New(ByVal AppType As
CECC.Financial2000.Global.Interfaces.ApplicationTypeAttribute.ApplicationPur
poseAttributeEnum)

AttributeEnum = AppType

End Sub

Public ReadOnly Property ApplicationAttribute() As
CECC.Financial2000.Global.Interfaces.ApplicationTypeAttribute.ApplicationPur
poseAttributeEnum

Get

Return AttributeEnum

End Get

End Property

End Class
 
Argh...guess I should have actually read the error message, and not tried to
put 2 & 2 together...

I consolidated 3 projects having child namespaces into a single project, and
put some of the project files into subdirectories, matching the namespace.
I also moved the old assemblyinfo.vb file into the subdirectory, but I
actually needed to delete it. :)
 
Back
Top