locked
RaiseEvent error in VB.net RRS feed

  • Question

  • Hello,

    I converted C# code to VB.net and am getting an error.

     

    C# code :

     public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
    System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
    if ((propertyChanged != null)) {
    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
    }
    }

    Translated VB.net Code :

    Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    1 Protected Sub RaisePropertyChanged(ByVal propertyName As String)
    2 Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChanged
    3 If (propertyChanged IsNot Nothing) Then
    4 propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
    5 End If
    End Sub

    i am getting the following error on 2nd line in the VB.net code at "Me.PropertyChanged":

    'Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

    Kindly let me know the changes I should make so as to make this code work.

     

    Thanks!

    Mahesh

    • Moved by Andrew_Zhu Monday, May 24, 2010 5:26 AM (From:.NET 3.0/3.5 Windows Workflow Foundation)
    Thursday, May 20, 2010 10:27 AM

All replies

  • Hi, Mahesh

    Do your question relate to WF3/3.5?
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support
    Monday, May 24, 2010 3:01 AM
  • Hi Andrew,

    It is related to WF/4.0

    Thanks & regards,

    Mahesh

     

    Monday, May 24, 2010 5:23 AM