ServerDocument.RemoveCustomization Yöntem
Özelleştirme belgeden kaldırır.
Ad alanı: Microsoft.VisualStudio.Tools.Applications
Derleme: Microsoft.VisualStudio.Tools.Applications.ServerDocument (Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll içinde)
Sözdizimi
'Bildirim
Public Shared Sub RemoveCustomization ( _
documentPath As String _
)
public static void RemoveCustomization(
string documentPath
)
Parametreler
- documentPath
Tür: System.String
Özelleştirmesini kaldırmak istediğiniz belgenin tam yolu.
Özel Durumlar
Exception | Koşul |
---|---|
ArgumentNullException | documentPath Parametresi nullnull başvuru (Visual Basic'te Nothing) veya boş ya da tamamen boşluk karakterlerinden oluşur. |
FileNotFoundException | Tarafından belirtilen dosya documentPath yok. |
IOException | Tarafından belirtilen dosya documentPath salt okunur veya erişilemiyor. |
InvalidOperationException | Tarafından belirtilen dosya documentPath mu değil bir özelleştirme veya bir hata oluşmuş liste yüklenirken. |
DocumentCustomizedWithPreviousRuntimeException | Tarafından belirtilen dosya documentPath ile Visual Studio 2010 Araçları Office çalışma zamanı veya Microsoft Office sistemi için Visual Studio Araçları için oluşturulmamış bir özelleştirme vardır (sürüm 3.0 çalışma zamanı). |
Notlar
Bu yöntem, dağıtım bildirimi URL'si ve önbelleğe alınan verileri bildirimini temizler ve belgeden tüm önbelleğe alınmış verileri kaldırır.Daha fazla bilgi için bkz. Nasıl Yapılır: Belgelerden Yönetilen Kod Uzantılarını Kaldırma.
Örnekler
Aşağıdaki kod örnek RemoveCustomization özelleştirme belirtilen belgeden kaldırmak için yöntem.İlk örnek aramaları GetCustomizationVersion bir özelleştirme belge olup olmadığını belirlemek için yöntem.
Bu örnek aşağıdakileri gerektirir:
Konsol uygulama projesi veya başka bir Office dışı proje.
Aşağıdaki derlemelere başvurular:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (durumunda proje hedefleri .NET Framework 4 veya .NET Framework 4.5).
veya
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (proje .NET Framework 3.5 hedefliyorsa).
Imports(Visual Basic için) veya using için (C#) deyimleri için Microsoft.VisualStudio.Tools.Applications ve Microsoft.VisualStudio.Tools.Applications.Runtime kod dosyanın üst ad.
Private Shared Sub RemoveAssembly(ByVal documentPath As String)
Dim runtimeVersion As Integer = 0
Try
' Make sure that this customization was created using the correct runtime.
runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
If runtimeVersion <> 3 Then
MessageBox.Show("This document does not have a Visual Studio Tools for Office " & _
"customization, or it has a customization that was created with a version of " & _
"the runtime that is incompatible with this version of the ServerDocument class.")
Return
End If
ServerDocument.RemoveCustomization(documentPath)
MessageBox.Show("The customization has been removed.")
Catch ex As System.IO.FileNotFoundException
System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
Catch ex As System.IO.IOException
System.Windows.Forms.MessageBox.Show("The specified document is read-only.")
Catch ex As UnknownCustomizationFileException
System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
"extension that is not supported by Visual Studio Tools for Office.")
Catch ex As InvalidOperationException
System.Windows.Forms.MessageBox.Show("The customization could not be removed." & _
vbLf & ex.Message)
End Try
End Sub
private static void RemoveAssembly(string documentPath)
{
int runtimeVersion = 0;
try
{
runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
// Make sure that this customization was created using the correct runtime.
if (runtimeVersion != 3)
{
MessageBox.Show("This document does not have a Visual Studio Tools for " +
"Office customization, or it has a customization that was created with " +
"a version of the runtime that is incompatible with this version of the " +
"ServerDocument class.");
return;
}
ServerDocument.RemoveCustomization(documentPath);
MessageBox.Show("The customization has been removed.");
}
catch (System.IO.FileNotFoundException)
{
System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
}
catch (System.IO.IOException)
{
System.Windows.Forms.MessageBox.Show("The specified document is read-only.");
}
catch (UnknownCustomizationFileException)
{
System.Windows.Forms.MessageBox.Show("The specified document has a file " +
"extension that is not supported by Visual Studio Tools for Office.");
}
catch (InvalidOperationException ex)
{
System.Windows.Forms.MessageBox.Show("The customization could not be removed.\n" +
ex.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.
Ayrıca bkz.
Başvuru
Microsoft.VisualStudio.Tools.Applications Ad Alanı
Diğer Kaynaklar
Nasıl Yapılır: Belgelerden Yönetilen Kod Uzantılarını Kaldırma