This documentation is archived and is not being maintained.

Non-shared members in a Structure cannot be declared 'New'

Visual Studio 2008

A nonshared variable in a structure is declared with a New clause.

You can initialize a shared reference variable in a structure, and you can have a nonshared reference variable without initialization, as the following code lines show.

Shared structVar1 As New System.ApplicationException

Dim structVar2 As System.ApplicationException

However, you cannot initialize a nonshared reference variable in a structure. The following code line is invalid.

Dim structVar3 As New System.ApplicationException ' INVALID IN A STRUCTURE

Error ID: BC30795

To correct this error

  • Remove either the Shared modifier or the New keyword from the reference variable declaration.