Freigeben über


VSProject2.WorkOffline-Eigenschaft

Gibt an, ob ein Webprojekt online oder offline ausgeführt wird. Bei der Offlineausführung wird die Entwicklung mit offline gespeicherten Projektdateien fortgeführt, und die Projektdateien auf dem Server bleiben unverändert.

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

Eigenschaftswert

Typ: Boolean
Ein boolescher Wert.Bei Webanwendungen gibt diese Eigenschaft bei der Offlineausführung true und bei der Onlineausführung false zurück.Bei lokalen Projekten gibt diese Eigenschaft false zurück.

Hinweise

Wenn das Projekt offline ist, wird kein Versuch unternommen, auf die Projektdateien auf dem Server zu schreiben oder zuzugreifen.

Die URL der Offlineprojektdateien ändern Sie mit der OfflineURL-Eigenschaft der Project.Properties-Auflistung.

Diese Eigenschaft kann nur bei Webprojekten geändert werden. Obgleich es sich um eine Schreib-/Leseeigenschaft handelt, wird eine Fehlermeldung ausgegeben, wenn Sie versuchen, sie für ein lokales Projekt festzulegen.

Beispiele

In diesem Beispiel wird davon ausgegangen, dass das erste Projekt in der Projektmappe ein Visual Basic- oder Visual C#-Projekt ist. Um dieses Beispiel als Add-In auszuführen, informieren Sie sich unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

[Visual Basic]

' 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 or C# 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

[C#]

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 or C# 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-Sicherheit

Siehe auch

Referenz

VSProject2 Schnittstelle

VSLangProj80-Namespace