Share via


VSProject2.WorkOffline Property

Indicates 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:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

Syntax

'Declaration
Property WorkOffline As Boolean
'Usage
Dim instance As VSProject2 
Dim value As Boolean 

value = instance.WorkOffline

instance.WorkOffline = value
bool WorkOffline { get; set; }
property bool WorkOffline {
    bool get ();
    void set (bool value);
}
function get WorkOffline () : boolean 
function set WorkOffline (value : boolean)

Property Value

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

Implements

VSProject.WorkOffline

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

This example assumes that the first project in the solution is a Visual Basic Visual C#, or Visual J# project. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

' Add-in code.
Imports VSLangProj
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    WorkOfflineExample(applicationObject)
End Sub

Sub WorkOfflineExample(ByVal dte As DTE2)
    ' This example assumes that the first project in the solution is 
    ' a Visual Basic, C#, or J# project.
    Dim aVSProject As VSProject2 = _
    CType(applicationObject.Solution.Projects.Item(1).Object,_
    VSProject2)
    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
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application, ext_ConnectMode
 connectMode, object addInInst, ref Array custom)
{ 
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    WorkOfflineExample((DTE2)applicationObject);
}

public void WorkOfflineExample( DTE2 dte ) 
{ 
// This example assumes that the first project in the solution is 
// a Visual Basic, C#, or J# project.
    VSProject2 aVSProject = ( ( VSProject2 )
(applicationObject.Solution.Projects.Item( 1 ).Object ) ); 
    MessageBox.Show( "Work offline is: " + 
aVSProject.WorkOffline.ToString()); 
    try 
    { 
        MessageBox.Show( "Setting WorkOffline to false."); 
        aVSProject.WorkOffline = false; 
    } 
    catch ( System.Exception e ) 
    { 
        // Setting the property fails for local projects.
        MessageBox.Show( e.Message); 
    } 
    try 
    { 
        MessageBox.Show( "Setting WorkOffline to true."); 
        aVSProject.WorkOffline = true; 
    } 
    catch ( System.Exception e ) 
    { 
        // Setting the property fails for local projects.
        MessageBox.Show( e.Message); 
    } 
}

.NET Framework Security

See Also

Reference

VSProject2 Interface

VSProject2 Members

WorkOffline Overload

VSLangProj80 Namespace