Aracılığıyla paylaş


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 belgeyi tam yolu.

Özel Durumlar

Exception Koşul
ArgumentNullException

documentPath Parametresi nullnull başvuru (Visual Basic'te Nothing) veya boş ya da tamamen beyaz boşluk karakterlerden oluşur.

FileNotFoundException

Belirtilen dosya documentPath yok.

IOException

Belirtilen dosya documentPath salt okunur veya erişilemiyor.

InvalidOperationException

Belirtilen dosya documentPath mu değil bir özelleştirme veya bir hata oluşmuş listesi yüklenirken.

DocumentCustomizedWithPreviousRuntimeException

Belirtilen dosya documentPath Office çalışma zamanı veya Microsoft Office sistemi için Visual Studio Araçları için Visual Studio 2010 araçlarıyla oluşturulmuş bir özelleştirme vardır (sürüm 3.0 Runtime).

Notlar

Bu yöntem, dağıtım bildirim URL'si ve önbelleğe alınan verileri bildirim 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ı kaldırma.

Örnekler

Aşağıdaki kod örneği RemoveCustomization özelleştirme belirtilen belgeden kaldırmak için yöntem.Örneğin ilk çağrı GetCustomizationVersion belge bir özelleştirme olup olmadığını saptamak için yöntem.

Bu örnek aşağıdakileri gerektirir:

  • Konsol uygulaması projesi veya başka bir Office proje.

  • Aşağıdaki derlemeler başvuruları:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (eğer proje .NET Framework 4'i hedefliyorsa).

      or

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (, Proje hedefleri.net Framework 3.5).

  • Imports(Visual Basic için) veya using (için C#) ifadeleri için Microsoft.VisualStudio.Tools.Applications ve Microsoft.VisualStudio.Tools.Applications.Runtime kod dosyanızı üstündeki 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

Ayrıca bkz.

Başvuru

ServerDocument Sınıf

Microsoft.VisualStudio.Tools.Applications Ad Alanı

Diğer Kaynaklar

Nasıl yapılır: belgelerden yönetilen kod uzantıları kaldırma