VSProject2.WorkOffline Özellik
Bir Web projesi çevrimiçi veya çevrimdışı çalışıp çalışmadığını gösterir.Çevrimdışı çalışırken, böylece proje dosyaları sunucuda değişmemiş geliştirme proje dosyaları, çevrimdışı bir depo devam eder.
Ad alanı: VSLangProj80
Derleme: VSLangProj80 (VSLangProj80.dll içinde)
Sözdizimi
'Bildirim
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)
Özellik Değeri
Tür: Boolean
Bir Boole değeri.Bu özellik, Web uygulamaları için döndürür true çevrimdışı çalışıyorsanız ve false çevrimiçi çalışıyorsanız.Yerel projeler için bu özellik döndürür false.
Notlar
Projeyi çevrimdışı olduğunda, yazmak veya proje dosyalarını sunucuya erişmek için girişimde bulunulmaz.
Çevrimdışı proje dosyalarının URL'sini değiştirmek için OfflineURL özelliği Project.Properties koleksiyonu.
Bu özellik yalnızca Web projeleri için değiştirilebilir.Bu bir okuma-yazma özelliği olmakla birlikte, yerel bir proje için bu özellik ayarlamayı denerseniz, bir hata oluşturulur.
Örnekler
Bu örnek çözümde ilk projeyi varsayar bir Visual Basic veya Visual C# proje.Bir eklenti bu örneği çalıştırmak için bkz: Nasıl yapılır: Otomasyon Nesne Modeli Kod Örnekleri Derleme ve Çalıştırma.
[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 Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. Kısmen Güvenilen Koddan Kitaplıkları Kullanma.