469,903 Members | 2,314 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

compile error after defining custom attribute

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.Cla ss, 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.ConfigurationAttri buteEnum)

End Get

End Property

Public ReadOnly Property IsSecurity() As Boolean

Get

Return (AttributeEnum =
ApplicationPurposeAttributeEnum.SecurityAttributeE num)

End Get

End Property

Public ReadOnly Property ApplicationAttribute() As
ApplicationPurposeAttributeEnum

Get

Return AttributeEnum

End Get

End Property

End Class

Nov 20 '05 #1
2 3389
I've simplified the attribute class, and added full namespaces,etc., and
still get the compile errors...
<System.AttributeUsage(System.AttributeTargets.Cla ss, 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.ApplicationTy peAttribute.ApplicationPur
poseAttributeEnum

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

AttributeEnum = AppType

End Sub

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

Get

Return AttributeEnum

End Get

End Property

End Class
Nov 20 '05 #2
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. :)
"Harry F. Harrison" <Ha************@sbcss.k12.ca.us> wrote in message
news:eX*************@tk2msftngp13.phx.gbl...
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.Cla ss, 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.ConfigurationAttri buteEnum)

End Get

End Property

Public ReadOnly Property IsSecurity() As Boolean

Get

Return (AttributeEnum =
ApplicationPurposeAttributeEnum.SecurityAttributeE num)

End Get

End Property

Public ReadOnly Property ApplicationAttribute() As
ApplicationPurposeAttributeEnum

Get

Return AttributeEnum

End Get

End Property

End Class

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Brice Prunier | last post: by
9 posts views Thread by Tyler | last post: by
6 posts views Thread by Javier Cortés Cortés | last post: by
7 posts views Thread by Yongsub Eric Shin | last post: by
6 posts views Thread by Terry Olsen | last post: by
5 posts views Thread by Sadeq | last post: by
2 posts views Thread by akhilesh.noida | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.