Partager via


VSProject.WorkOffline Property

Gets or sets whether a Web project is working online or offline. When it is working offline, development continues on an offline store of project files, so that the project files on the server are not changed.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

Syntax

'Declaration
Property WorkOffline As Boolean
bool WorkOffline { get; set; }
property bool WorkOffline {
    bool get ();
    void set (bool value);
}
abstract WorkOffline : bool with get, set
function get WorkOffline () : boolean 
function set WorkOffline (value : boolean)

Property Value

Type: Boolean
For Web applications, this property returns true if working offline and false if working online. For local projects, this property returns false.

Remarks

When the project is offline, no attempt is made to write to or access the project's files on the server.

To change the URL of the offline project files, use the OfflineURL property of the Project.Properties collection.

This property may be changed for Web projects only. While this is a read-write property, an error is generated if you attempt to set this property for a local project.

Examples

[Visual Basic]

' Macro editor
Imports VSLangProj
Sub WorkOfflineExample()
   ' This example assumes that the first project in the solution is 
   ' either a Visual Basic or C# project.
   Dim aVSProject As VSProject = _
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)
        
   msgbox("Work offline is: " & aVSProject.WorkOffline.ToString())
   Try
      MsgBox ("Setting WorkOffline to false.")
      aVSProject.WorkOffline = False
   Catch e As System.Exception
      ' Setting the property fails for local projects.
      MsgBox(e.Message)
   End Try
        
   Try
      MsgBox ("Setting WorkOffline to true.")
      aVSProject.WorkOffline = True
   Catch e As System.Exception
      ' Setting the property fails for local projects.
      MsgBox(e.Message)
   End Try
End Sub

.NET Framework Security

See Also

Reference

VSProject Interface

VSLangProj Namespace