This documentation is archived and is not being maintained.

My.Application.Deployment Property 

Gets the current application's ClickOnce deployment object, which provides support for updating the current deployment programmatically and support for the on-demand download of files.


' Usage
Dim value As System.Deployment.Application.ApplicationDeployment = My.Application.Deployment
' Declaration
Public ReadOnly Property Deployment As System.Deployment.Application.ApplicationDeployment

Returns the ApplicationDeployment object for the application's ClickOnce deployment.

The following condition can cause an exception:

The My.Application.Deployment property returns the application's ClickOnce ApplicationDeployment object. The ApplicationDeployment object provides support for updating the current deployment programmatically as well as support for the on-demand download of files. For more information on ClickOnce applications and how to deploy them, see ClickOnce Deployment and Publishing ClickOnce Applications.

Check the My.Application.IsNetworkDeployed Property before accessing the My.Application.Deployment property. Otherwise, if the application is not deployed using ClickOnce, reading the My.Application.Deployment property results in an InvalidDeploymentException exception. For more information on deploying a ClickOnce application, see How to: Publish a ClickOnce Application.

For more information on using the My.Application.Deployment property, see Overview of the Visual Basic Application Model.

The following table lists examples of tasks involving the My.Application.Deployment property.

To See

Check for an application update

How to: Check for ClickOnce Application Updates

Download an application update

How to: Download ClickOnce Application Updates

This example downloads and installs the update after checking that the application is network-deployed. The Update method does not update the application unless it is out of date. The application has to restart to use the update. For more information, see How to: Download ClickOnce Application Updates.

Sub UpdateApplication()
    If My.Application.IsNetworkDeployed Then
        My.Application.Deployment.Update()
    End If
End Sub

Only applications that are ClickOnce deployed can be updated using the My.Application.Deployment object. For more information on deploying a ClickOnce application, see How to: Publish a ClickOnce Application.

Namespace: Microsoft.VisualBasic.ApplicationServices

Class: ConsoleApplicationBase

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type Available

Windows Application

Yes

Class Library

No

Console Application

Yes

Windows Control Library

No

Web Control Library

No

Windows Service

Yes

Web Site

No

The following permission may be necessary:

Permission Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

Show: