Applying custom attribute causes VS2008/VB Compiler Crash

Last post 06-13-2009 6:32 AM by Jaap78. 6 replies.

Sort Posts:

  • Applying custom attribute causes VS2008/VB Compiler Crash

    01-12-2008, 5:59 PM
    • Contributor
      2,385 point Contributor
    • imagemaker
    • Member since 03-26-2004, 8:57 PM
    • Maine
    • Posts 466

    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.

     

    Bill, WESNet Designs
  • Re: Applying custom attribute causes VS2008/VB Compiler Crash

    01-12-2008, 6:22 PM
    Answer
    • All-Star
      21,648 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,177

     That is clearly a bug in Intellisense. You should file a bug report at http://connect.microsoft.com/VisualStudio/Feedback

     

    -- "Mark As Answer" if my reply helped you --
  • Re: Applying custom attribute causes VS2008/VB Compiler Crash

    01-12-2008, 9:13 PM
    • Contributor
      2,385 point Contributor
    • imagemaker
    • Member since 03-26-2004, 8:57 PM
    • Maine
    • Posts 466

    It sure looks that way although extensive searches of MSDN forums/feedback tracker did not show any similar bugs. As my install of VS2008 RTM (actually retail purchased upgrade) was installed after following all steps to remove Beta 2, it may just be a problem with my installation.

    I also tried the equivalent code in C# without experiencing the crash.

    Thanks for your suggestion to post to the Feedback tracker.  I'll do that now.

    Bill, WESNet Designs
  • Re: Applying custom attribute causes VS2008/VB Compiler Crash

    02-01-2008, 3:59 PM
    • Member
      4 point Member
    • karl1406
    • Member since 12-15-2006, 6:31 PM
    • Posts 12

    I'm getting the same thing.  :-(

    I have 7 custom attributes and only one of them crashes VS2008.  The code is structured the same.

    The same code works in VS2005.

    Bummer,

    Karl

  • Re: Applying custom attribute causes VS2008/VB Compiler Crash

    02-01-2008, 5:16 PM
    • All-Star
      21,648 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,177
  • Re: Applying custom attribute causes VS2008/VB Compiler Crash

    02-02-2008, 10:40 AM
    • Member
      4 point Member
    • karl1406
    • Member since 12-15-2006, 6:31 PM
    • Posts 12

    I had the same exact problem.

    I have posted on my blog how to correct this:

     http://karlshifflett.wordpress.com/2008/02/02/visual-studio-2008-crashes-when-applying-custom-attribute-bug-and-solution/

     There is even a short video explaining the problem and the workaround.

     Very easy to fix and or workaround.

     Karl

  • Re: Applying custom attribute causes VS2008/VB Compiler Crash

    06-13-2009, 6:32 AM
    • Member
      2 point Member
    • Jaap78
    • Member since 06-13-2009, 6:07 AM
    • Posts 1
    This problem bugged me for hours. VS2008 would crash every time I opened my solution.
    None of the solutions I found online were helpful.
    The above post from Karl didn't apply to my situation, since I did not have an empty constructor for my attribute.

    However I have finally been able to fix it by removing: <AttributeUsage(AttributeTargets.Property)>
    from my attribute class.
    Even though this thread is over a year old, I thought I'd share this here.
    Hopefully it will save someone some frustration.

    Jaap
Page 1 of 1 (7 items)