Visual Basic breaking changes in .NET Core 3.0

The following is a list of breaking changes in Visual Basic:

.NET Core 3.0

Types in Microsoft.VisualBasic.ApplicationServices namespace not available

The types in the Microsoft.VisualBasic.ApplicationServices namespace are not available.

Version introduced

.NET Core 3.0

Change description

The types in the Microsoft.VisualBasic.ApplicationServices namespace were available in .NET Framework. They're not available in .NET Core 3.0 - 3.1.

The types were removed to avoid unnecessary assembly dependencies or breaking changes in subsequent releases.

This namespace was added in .NET 5, upgrade your project to .NET 5 or later.

-or-

If your code depends on the use of Microsoft.VisualBasic.ApplicationServices types and their members, you may be able to use a corresponding type or member in the .NET class library. For example, some System.Environment and System.Security.Principal.WindowsIdentity members provide equivalent functionality to the properties of the Microsoft.VisualBasic.ApplicationServices.User class.

Category

Visual Basic

Affected APIs


Types in Microsoft.VisualBasic.Devices namespace not available

The types in the Microsoft.VisualBasic.Devices namespace are not available.

Version introduced

.NET Core 3.0

Change description

The types in the Microsoft.VisualBasic.Devices namespace were available in .NET Framework. They're not available in .NET Core 3.0 - 3.1.

The types were removed to avoid unnecessary assembly dependencies or breaking changes in subsequent releases.

This namespace was added in .NET 5, upgrade your project to .NET 5 or later.

-or-

If your code depends on the use of Microsoft.VisualBasic.Devices types and their members, you may be able to use a corresponding type or member in the .NET class library. For example, equivalent functionality to the Microsoft.VisualBasic.Devices.Clock class is provided by the System.DateTime and System.Environment types, and equivalent functionality to the Microsoft.VisualBasic.Devices.Ports class is provided by types in the System.IO.Ports namespace.

Category

Visual Basic

Affected APIs


Types in Microsoft.VisualBasic.MyServices namespace not available

The types in the Microsoft.VisualBasic.MyServices namespace are not available.

Version introduced

.NET Core 3.0

Change description

The types in the Microsoft.VisualBasic.MyServices namespace were available in .NET Framework. They're not available in .NET Core 3.0 - 3.1.

The types were removed to avoid unnecessary assembly dependencies or breaking changes in subsequent releases.

This namespace was added in .NET 5, upgrade your project to .NET 5 or later.

-or-

If your code depends on the use of Microsoft.VisualBasic.MyServices types and their members, there are corresponding types and members in the .NET class library. The following is a mapping of Microsoft.VisualBasic.MyServices types to their equivalent .NET class library types:

Microsoft.VisualBasic.MyServices type .NET class library type
ClipboardProxy System.Windows.Clipboard for WPF applications, System.Windows.Forms.Clipboard for Windows Forms applications
FileSystemProxy Types in the System.IO namespace
RegistryProxy Registry-related types in the Microsoft.Win32 namespace
SpecialDirectoriesProxy Environment.GetFolderPath

Category

Visual Basic

Affected APIs


About and SplashScreen templates are broken

The About.vb and SplashScreen.vb files generated by Visual Studio contain references to types in the My namespace that aren't available .NET Core 3.0 and 3.1.

Version introduced

3.0

Change description

.NET Core 3.0 and 3.1 don't contain full Visual Basic My support. The About and SplashScreen form templates in Visual Studio for Visual Basic Windows Forms apps reference properties in the My.Application.Info type that aren't available.

Visual Basic My support was improved in .NET 5, upgrade your project to .NET 5 or later.

-or-

Fix the compiler errors in the About and SplashScreen types in your app. Use the System.Reflection.Assembly class to get the information provided by the My.Application.Info type. A straight port of both forms is available here.

Tip

This is sample code and unoptimized. The list of attributes should be cached to reduce form load time.

About

Imports System.Reflection

Public NotInheritable Class About

    Private Sub about_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Set the title of the form.
        Dim applicationTitle As String = Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyTitleAttribute)()?.Title

        If String.IsNullOrEmpty(applicationTitle) Then
            applicationTitle = System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().GetName().Name)
        End If

        Me.Text = String.Format("About {0}", applicationTitle)
        ' Initialize all of the text displayed on the About Box.
        ' TODO: Customize the application's assembly information in the "Application" pane of the project
        '    properties dialog (under the "Project" menu).
        Me.LabelProductName.Text = If(Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyProductAttribute)()?.Product, "")
        Me.LabelVersion.Text = String.Format("Version {0}", Assembly.GetExecutingAssembly().GetName().Version)
        Me.LabelCopyright.Text = If(Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyCopyrightAttribute)()?.Copyright, "")
        Me.LabelCompanyName.Text = If(Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyCompanyAttribute)()?.Company, "")
        Me.TextBoxDescription.Text = If(Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyDescriptionAttribute)()?.Description, "")
    End Sub

    Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
        Me.Close()
    End Sub

End Class

SplashScreen

Imports System.Reflection

Public NotInheritable Class SplashScreen

    Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the dialog text at runtime according to the application's assembly information.  

        'TODO: Customize the application's assembly information in the "Application" pane of the project
        '  properties dialog (under the "Project" menu).

        'Application title
        Dim appTitle As String = Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyTitleAttribute)()?.Title

        If String.IsNullOrEmpty(appTitle) Then
            appTitle = System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().GetName().Name)
        End If

        ApplicationTitle.Text = appTitle

        Dim versionValue = Assembly.GetExecutingAssembly().GetName().Version

        'Format the version information using the text set into the Version control at design time as the
        '  formatting string.  This allows for effective localization if desired.
        '  Build and revision information could be included by using the following code and changing the
        '  Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar.  See
        '  String.Format() in Help for more information.
        '
        '    Version.Text = System.String.Format(Version.Text, versionValue.Major, versionValue.Minor, versionValue.Build, versionValue.Revision)

        Version.Text = System.String.Format(Version.Text, versionValue.Major, versionValue.Minor)

        'Copyright info
        Copyright.Text = If(Assembly.GetExecutingAssembly().GetCustomAttribute(Of AssemblyCopyrightAttribute)()?.Copyright, "")
    End Sub

End Class

Category

Visual Basic Windows Forms

Affected APIs

None