Share via


ServerDocument.GetCustomizationVersion 메서드

지정된 문서와 연결되는 사용자 지정을 만드는 데 사용된 Microsoft Visual Studio Tools for Office Runtime의 버전을 반환합니다.

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

구문

‘선언
Public Shared Function GetCustomizationVersion ( _
    documentPath As String _
) As Integer
public static int GetCustomizationVersion(
    string documentPath
)

매개 변수

  • documentPath
    형식: System.String
    확인할 문서의 전체 경로입니다.

반환 값

형식: System.Int32
연결된 사용자 지정을 만드는 데 사용된 Microsoft Visual Studio Tools for Office Runtime의 버전을 지정하는 번호입니다.

예외

예외 상황
ArgumentNullException

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

FileNotFoundException

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

UnknownCustomizationFileException

documentPath로 지정된 파일의 파일 확장명이 Microsoft Visual Studio Tools for Office Runtime에서 지원되지 않는 경우

설명

서로 다른 버전의 Visual Studio에서 만든 Office 솔루션은 다른 버전의 Microsoft Visual Studio Tools for Office Runtime을 사용합니다. 각 버전의 런타임에서는 해당 버전의 런타임에 대한 솔루션에서 사용할 수 있는 각기 다른 버전의 ServerDocument 클래스를 제공합니다. 이 버전의 ServerDocument 클래스는 Visual Studio 2010을 사용하여 만든 솔루션과 Visual Studio 2008을 사용하여 만든 2007 Microsoft Office 솔루션을 함께 사용할 수 있습니다.

다음 표에서는 이 메서드의 반환 값에 대한 의미를 설명합니다.

반환 값

설명

0

문서에 사용자 지정이 없는 경우

1

문서에 Visual Studio Tools for Office, Version 2003을 사용하여 만든 사용자 지정이 있습니다.

2

문서에 Visual Studio 2005 Tools for Office Second Edition Runtime을 사용하여 만든 사용자 지정이 있습니다. Visual Studio 2005 Tools for Office 및 Visual Studio 2008에서 Microsoft Office 2003을 사용자 지정하는 데 사용되는 런타임 버전입니다.

3

문서에 the Visual Studio 2010 Tools for Office Runtime 또는 Microsoft Office 시스템용 Visual Studio 도구(버전 3.0 Runtime)를 사용하여 만들어진 사용자 지정이 있습니다. 버전 3.0 Runtime은 Visual Studio 2008에서 2007 Microsoft Office 시스템에 대한 사용자 지정에 사용됩니다.

Microsoft Visual Studio Tools for Office Runtime의 다른 버전에 대한 자세한 내용은 Visual Studio Tools for Office 런타임 개요를 참조하십시오.

예제

다음 코드 예제에서는 지정된 문서를 로드한 다음 문서에 연결된 사용자 지정에 대한 배포 매니페스의 URL을 표시하는 새 ServerDocument를 만듭니다. 개체를 만들기 전에 코드에서는 GetCustomizationVersion 메서드를 사용하여 사용자 지정이 Visual Studio 2010 Tools for Office Runtime을 사용하여 만들어졌는지 확인합니다.

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

  • 콘솔 응용 프로그램 프로젝트 또는 다른 비 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 Sub CreateServerDocumentFromPath(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion = 3 Then
            serverDocument1 = New ServerDocument(documentPath)
            MessageBox.Show("The URL of the deployment manifest is: " & vbLf & _
                serverDocument1.DeploymentManifestUrl.ToString())
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    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.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
    End Try
End Sub
private void CreateServerDocumentFromPath(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
        if (runtimeVersion == 3)
        {
            serverDocument1 = new ServerDocument(documentPath);
            MessageBox.Show("The URL of the deployment manifest is: \n" +
                serverDocument1.DeploymentManifestUrl.ToString());
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
    }
}

.NET Framework 보안

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

참고 항목

참조

ServerDocument 클래스

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

기타 리소스

ServerDocument 클래스를 사용하여 서버의 문서 관리