Click here to Skip to main content
15,886,781 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,

I've run into an issue that has me scratching my head and I'm hoping somebody has experienced a similar issue...

I have a user control that has a custom event handler. When adding a handle to this event from a separate winforms project, visual studio crashes with the below exception,

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: exception code 8004753b, exception address 7786CBB2
Stack:


I have narrowed it down to the constructor of the event being the cause but I don't understand as to why. When I remove the argument and code of the constructor, I have no issues.

Not working,

VB
Public Class PromotionEventArgs
    Inherits EventArgs

    Private _quantity As Integer

    Public Sub New(ByVal Quantity As Integer)
        _quantity = Quantity
    End Sub

    Public ReadOnly Property Quantity As Integer
        Get
            Return _quantity
        End Get
    End Property
End Class


Working,

VB
Public Class PromotionEventArgs
    Inherits EventArgs

    Private _quantity As Integer

    Public Sub New()
    End Sub

    Public ReadOnly Property Quantity As Integer
        Get
            Return _quantity
        End Get
    End Property
End Class


What I have tried:

Debugging the user control in design time

Clearing the Visual Studio cache

Cleaning and rebuilding the entire solution
Posted
Comments
phil.o 8-Dec-17 6:05am    
What could be useful also is the definition of the event handler (delegate and/or event), as well as the part in code where the event is raised.
Shaynec 8-Dec-17 6:56am    
Thank you, requesting this made me re-examine that part of the code and I found the actual cause of the issue. The delegate was named "Add" and I have an ExtensionAttribute that is also named "Add" in another project within the same solution. Apparently this is enough to confuse Visual Studio :)
phil.o 8-Dec-17 7:01am    
You are welcome :)
Mehdi Gholam 8-Dec-17 6:25am    
Try VS2017 CE
Shaynec 8-Dec-17 6:57am    
Hopefully next year :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900