VSProject2.WorkOffline Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Gibt an, ob ein Webprojekt online oder offline funktioniert. Wenn Sie offline arbeitet, wird die Entwicklung in einem Offline-Speicher von Projektdateien fortgesetzt, sodass die Projektdateien auf dem Server nicht geändert werden.
public:
property bool WorkOffline { bool get(); void set(bool value); };
public:
property bool WorkOffline { bool get(); void set(bool value); };
[System.Runtime.InteropServices.DispId(10)]
public bool WorkOffline { [System.Runtime.InteropServices.DispId(10)] get; [System.Runtime.InteropServices.DispId(10)] set; }
[<System.Runtime.InteropServices.DispId(10)>]
[<get: System.Runtime.InteropServices.DispId(10)>]
[<set: System.Runtime.InteropServices.DispId(10)>]
member this.WorkOffline : bool with get, set
Public Property WorkOffline As Boolean
Eigenschaftswert
Ein boolescher Wert. Bei Webanwendungen gibt diese Eigenschaft true zurück, wenn Sie offline arbeiten, und false, wenn Sie online arbeiten. Für lokale Projekte gibt diese Eigenschaft false zurück.
Implementiert
- Attribute
Beispiele
In diesem Beispiel wird davon ausgegangen, dass das erste Projekt in der Projekt Mappe ein- Visual Basic oder- Visual C# Projekt ist. Informationen zum Ausführen dieses Beispiels als Add-in finden Sie unter Gewusst wie: Kompilieren und Ausführen der Code Beispiele für das Automatisierungs Objektmodell.
[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);
}
}
Hinweise
Wenn das Projekt offline ist, wird nicht versucht, auf die Projektdateien auf dem Server zu schreiben oder darauf zuzugreifen.
Um die URL der Offline Projektdateien zu ändern, verwenden Sie die- OfflineURL Eigenschaft der-Auflistung Project.Properties .
Diese Eigenschaft kann nur für Webprojekte geändert werden. Obwohl es sich um eine Lese-/Schreibeigenschaft handelt, wird ein Fehler generiert, wenn Sie versuchen, diese Eigenschaft für ein lokales Projekt festzulegen.