By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

compile error after defining custom attribute

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.