ServerDocument.RemoveCustomization(String) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Özelleştirmeyi belgeden kaldırır.
public static void RemoveCustomization (string documentPath);
Parametreler
- documentPath
- String
Özelleştirmeyi kaldırmak istediğiniz belgenin tam yolu.
Özel durumlar
documentPath
Parametresi null
veya boş ya da tamamen boşluk karakterlerinden oluşur.
Tarafından belirtilen dosya documentPath
yok.
Tarafından belirtilen dosya documentPath
salt okunurdur veya erişilemez.
Tarafından belirtilen dosya documentPath
bir özelleştirmeye sahip değil veya bildirim yüklenirken bir hata oluştu.
Tarafından belirtilen dosya, documentPath
Office çalışma zamanı Için Visual Studio 2010 araçları veya Microsoft Office sistemi için Visual Studio Araçları (sürüm 3,0 çalışma zamanı) ile oluşturulmamış bir özelleştirmeye sahip.
Örnekler
Aşağıdaki kod örneği, RemoveCustomization belirtilen belgeden özelleştirmeyi kaldırmak için yöntemini kullanır. Örnek öncelikle GetCustomizationVersion belgenin bir özelleştirmeye sahip olup olmadığını belirlemede yöntemini çağırır.
Bu örnek şunları gerektirir:
Bir konsol uygulaması projesi veya başka bir Office dışı proje.
Aşağıdaki derlemelere başvurur:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (proje veya ' i hedefliyorsa .NET Framework 4 .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'i hedefliyorsa).
Imports
(for Visual Basic) veyausing
(for C#) deyimleri, Microsoft.VisualStudio.Tools.Applications ve için Microsoft.VisualStudio.Tools.Applications.Runtime Kod dosyanızın en üstünde bulunan ad alanları.
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);
}
}
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
Açıklamalar
Bu yöntem, dağıtım bildirimi URL 'sini ve önbelleğe alınmış veri bildirimini temizler ve belgedeki 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.