Why would the VB.NET compiler think an interface isn't implemented when it is?

Posted by Dan Tao on Stack Overflow See other posts from Stack Overflow or by Dan Tao
Published on 2010-04-09T15:57:53Z Indexed on 2010/04/09 16:03 UTC
Read the original article Hit count: 393

I have this happen sometimes, particularly with the INotifyPropertyChanged interface in my experience but I have no idea if the problem is limited to that single interface (which would seem bizarre) or not.

Let's say I have some code set up like this. There's an interface with a single event. A class implements that interface. It includes the event.

Public Interface INotifyPropertyChanged
    Event PropertyChanged As PropertyChangedEventHandler
End Interface

Public Class Person
    Implements INotifyPropertyChanged

    Public Event PropertyChanged _
    (ByVal sender As Object, ByVal e As PropertyChangedEventArgs) _
        Implements INotifyPropertyChanged.PropertyChanged

    ' more code below '
End Class

Every now and then, when I build my project, the compiler will suddenly start acting like the above code is broken. It will report that the Person class does not implement INotifyPropertyChanged because it doesn't have a PropertyChanged event; or it will say the PropertyChanged event can't implement INotifyPropertyChanged.PropertyChanged because their signatures don't match.

This is weird enough as it is, but here's the weirdest part: if I just cut out the line starting with Event PropertyChanged and then paste it back in, the error goes away. The project builds.

Does anybody have any clue what could be going on here?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about interface