'Using' resource variable must have an explicit initialization

A Using statement specifies at least one resource that it does not initialize with a New clause.

If you have not already acquired the resource before passing control to the Using block, the Using statement must acquire the resource. To do this, it must create an object from the specified class, which requires a New clause.

Error ID: BC36011

To correct this error

  • If you have already acquired the resource, use a reference variable or expression in the Using statement that evaluates to the acquired resource.

    Dim newFont As New System.Drawing.Font

    Using newFont

  • If you have not already acquired the resource, add a New clause to the Using statement.

    Using newFont as New System.Drawing.Font

See Also

Tasks

How to: Dispose of a System Resource

Reference

Using Statement (Visual Basic)

New (Visual Basic)