Has anyone had problems creating and applying a custom attribute in VB in VS2008 Professional (ver 9.0.21022.8)? While working on ASP.NET solution with many projects I defined a new custom attribute (targeting properties) and successfully rebuilt the project. However, when applying the new attribute to a property, VS2008 would repeatedly crash as soon as the opening parenthesis of the attribute (i.e. <ClientAlias( ) was typed with the following error message:
"Microsoft(R) Visual Basic Compiler has stopped working...A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."
Following each crash, the application log shows the following:
Log Name: Application
Source: Application Error
Date: 1/12/2008 5:17:49 PM
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: P5K-Bill
Description:
Faulting application devenv.exe, version 9.0.21022.8, time stamp 0x47317b3d, faulting module kernel32.dll, version 6.0.6000.16386, time stamp 0x4549bd80, exception code 0x80070057, fault offset 0x0001b09e, process id 0x2f8, application start time 0x01c85567134ca534.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2008-01-12T22:17:49.000Z" />
<EventRecordID>28860</EventRecordID>
<Channel>Application</Channel>
<Computer>P5K-Bill</Computer>
<Security />
</System>
<EventData>
<Data>devenv.exe</Data>
<Data>9.0.21022.8</Data>
<Data>47317b3d</Data>
<Data>kernel32.dll</Data>
<Data>6.0.6000.16386</Data>
<Data>4549bd80</Data>
<Data>80070057</Data>
<Data>0001b09e</Data>
<Data>2f8</Data>
<Data>01c85567134ca534</Data>
</EventData>
</Event>
The OS is Windows Vista Business with all current updates applied.
If one applys the custom attribute without typing the opening parenthesis, the non-parameterized attribute constructor will be utilized without error. In this case, the IDE reformats the line to include the parenthesis i.e. <ClientAlias()> _
Thinking that the large multi-project solution I was working on might be the source of the problem, I then created the following simple VB class library - one simple custom attribute and one class containing one property:
Namespace WESNet
<AttributeUsage(AttributeTargets.Property)> _
Public NotInheritable Class ClientAliasAttribute
Inherits System.Attribute
Private _clientAlias As String
Public Sub New()
End Sub
Public Sub New(ByVal clientAlias As String)
Me._clientAlias = clientAlias
End Sub
Public Overrides Function IsDefaultAttribute() As Boolean
Return String.IsNullOrEmpty(Me._clientAlias)
End Function
Public ReadOnly Property ClientAlias() As String
Get
Return Me._clientAlias
End Get
End Property
End Class
Public Class AttributeTest
Dim _ID As String
'<ClientAlias ("ctlID")> _
Public Property ID() As String
Get
Return _ID
End Get
Set(ByVal value As String)
_ID = value
End Set
End Property
End Class
End Namespace
Although the project would build without error, as soon as I typed the opening parenthesis in "<ClientAlias( " to apply the attribute to the above ID property . . . the error occured. I also tried several variations of the custom attribute definition. Anytime the custom attribute included both a default, non-parameterized constructor and one or more parameterized constructors, the same error would occur when typing the opening parenthesis.
EDIT: Interestingly, if I start the line applying the custom attribute with a comment (as above) then REMOVE the comment marker, all is well. However, as soon as I try to backspace into the parenthesis, the same error occurs.