Click here to Skip to main content
13,703,250 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.5K views
6 bookmarked
Posted 17 Nov 2009
Licenced CPOL

Visual Studio 2010 – Visual Basic New Feature – NonSerialized Events

, 17 Nov 2009
Rate this:
Please Sign up or sign in to vote.
A long time feature request has been added to Visual Basic 10 that ships with Visual Studio 2010; decorating an Event as NonSerialized.

A long time feature request has been added to Visual Basic 10 that ships with Visual Studio 2010; decorating an Event as NonSerialized.

In prior versions of Visual Basic, developers had to implement a Custom Event or another workaround when their types needed to expose an Event and they had to be Serializable. C# had this capability, now Visual Basic does too!

A very common scenario is a class that implements INotifyPropertyChanged and must also be Serializable.

Visual Basic developers can now decorate the Event with the NonSerialized attribute. The compiler does the rest for you.

Imports System.ComponentModel

<Serializable()>
Public Class Customer
    Implements INotifyPropertyChanged

#Region " INotifyPropertyChanged Serializable "
 
    'New VB 10 feature!
    <NonSerialized()>
    Public Event PropertyChanged(
                  ByVal sender As Object,
                  ByVal e As System.ComponentModel.PropertyChangedEventArgs) _
                  Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Protected Sub OnPropertyChanged(ByVal strPropertyName As String)
        If Me.PropertyChangedEvent IsNot Nothing Then
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(strPropertyName))
        End If
    End Sub

#End Region

End Class

Have a great day.

Just a grain of sand on the world's beaches.

Posted in CodeProject, Tips, VB.NET, Visual Studio 2010, WPF General

License

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

Share

About the Author

Karl Shifflett
Architect Infragistics
United States United States

I’m a passionate Platform Architect at Infragistics.


I’m a long-time WPF-Prism fanatic who enjoys writing developer tools and line of business applications.


My current front end passions are: XAML platforms (Xamarin.Forms, Xamarin, UWP, and WPF), Electron, ES2015 (ES6), Node.js, Aurelia, and AngularJS (Angular 1.5.x).


For the back end I use what is appropriate for the project: SQL Server and ASP.NET WebAPI, MongoDB, Express, Azure, Firebase, etc.


I am very pragmatic software engineer and strive to write simple, maintainable, and testable code. Simple code allows for solving complex problems in a maintainable way.


My Blog


My Github Repros


My YouTube Videos


Just a grain of sand on the worlds beaches.


You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180920.1 | Last Updated 17 Nov 2009
Article Copyright 2009 by Karl Shifflett
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid