ServerDocument.RemoveCustomization 메서드

문서에서 사용자 지정을 제거합니다.

네임스페이스:  Microsoft.VisualStudio.Tools.Applications
어셈블리:  Microsoft.VisualStudio.Tools.Applications.ServerDocument(Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)

구문

‘선언
Public Shared Sub RemoveCustomization ( _
    documentPath As String _
)
public static void RemoveCustomization(
    string documentPath
)

매개 변수

  • documentPath
    형식: System.String
    사용자 지정을 제거할 문서에 대한 전체 경로입니다.

예외

예외 상황
ArgumentNullException

documentPath 매개 변수가 nullNull 참조(Visual Basic의 경우 Nothing)이거나, 비어 있거나, 모두 공백 문자로 이루어져 있는 경우

FileNotFoundException

documentPath에 지정된 파일이 없는 경우

IOException

documentPath에 지정된 파일이 읽기 전용이거나 이 파일에 액세스할 수 없는 경우

InvalidOperationException

documentPath로 지정된 파일에 사용자 지정이 없거나, 매니페스트를 로드하는 동안 오류가 발생한 경우

DocumentCustomizedWithPreviousRuntimeException

documentPath로 지정된 파일이 Visual Studio 2010 Tools for Office Runtime 또는 Microsoft Office 시스템(버전 3.0 런타임)용 Visual Studio 도구를 사용하여 만들지 않은 사용자 지정이 있습니다.

설명

이 메서드를 사용하면 배포 매니페스트 URL 및 캐시된 데이터 매니페스트가 지워지고 캐시된 데이터가 문서에서 모두 제거됩니다. 자세한 내용은 방법: 문서에서 관리 코드 확장 제거을 참조하십시오.

예제

다음 코드 예제에서는 RemoveCustomization 메서드를 사용하여 지정된 문서에서 사용자 지정을 제거합니다. 먼저 GetCustomizationVersion 메서드를 호출하여 문서에 사용자 지정이 있는지 여부를 확인합니다.

이 예제에는 다음 사항이 필요합니다.

  • 콘솔 응용 프로그램 프로젝트 또는 다른 비 Office 프로젝트입니다.

  • 다음 어셈블리에 대한 참조:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.dll(.NET Framework 4를 대상으로 하는 프로젝트의 경우)

      또는

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll(.NET Framework 3.5를 대상으로 하는 프로젝트의 경우)

  • 코드 파일 상단에 있는 Microsoft.VisualStudio.Tools.ApplicationsMicrosoft.VisualStudio.Tools.Applications.Runtime 네임스페이스에 대해 Imports(Visual Basic의 경우) 또는 using(C#의 경우) 문.

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 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

ServerDocument 클래스

Microsoft.VisualStudio.Tools.Applications 네임스페이스

기타 리소스

방법: 문서에서 관리 코드 확장 제거