다음을 통해 공유


ServerDocument 클래스

Visual Studio의 Office 개발 도구를 사용하여 만든 문서 수준 사용자 지정의 일부인 문서나 통합 문서에 있는 캐시된 데이터 및 사용자 지정 정보에 대한 액세스를 제공합니다.

상속 계층 구조

System.Object
  Microsoft.VisualStudio.Tools.Applications.ServerDocument

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

구문

‘선언
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class ServerDocument _
    Implements IDisposable
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class ServerDocument : IDisposable

ServerDocument 형식에서는 다음과 같은 멤버를 노출합니다.

생성자

  이름 설명
Public 메서드 ServerDocument(String) 로드할 문서의 전체 경로를 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.
Public 메서드 ServerDocument(array<Byte[], String) 로드할 문서를 나타내는 바이트 배열과 해당 문서의 파일 확장명을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.
Public 메서드 ServerDocument(Stream, String) 로드할 문서를 나타내는 스트림과 해당 문서의 파일 확장명을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.
Public 메서드 ServerDocument(String, FileAccess) 로드할 문서의 전체 경로와 해당 문서에 대한 파일 액세스를 나타내는 값을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

위쪽

속성

  이름 설명
Public 속성 CachedData 문서에 들어 있는 캐시된 데이터를 나타내는 CachedData 개체를 가져옵니다.
Public 속성 DeploymentManifestUrl 문서와 연결된 사용자 지정에 대한 배포 매니페스트 URL을 가져오거나 설정합니다.
Public 속성 Document ServerDocument 에 로드되는 메모리 내 문서의 바이트 배열을 가져옵니다.
Public 속성 SolutionId Microsoft Visual Studio Tools for Office Runtime에서 솔루션을 식별하는 데 사용하는 GUID를 가져옵니다.

위쪽

메서드

  이름 설명
Public 메서드정적 멤버 AddCustomization(String, Uri) 지정된 어셈블리 이름 및 배포 매니페스트를 사용하여 지정된 문서에 사용자 지정을 연결합니다.
Public 메서드정적 멤버 AddCustomization(String, String, Guid, Uri) 지정된 문서, 어셈블리 이름, 솔루션 ID 및 배포 매니페스트를 사용하여 지정된 문서에 사용자 지정을 연결합니다.
Public 메서드정적 멤버 AddCustomization(String, String, Guid, Uri, Boolean, array<String[]%) 인프라입니다.
Public 메서드 Close ServerDocument 개체를 닫습니다.
Public 메서드 Equals 지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (Object에서 상속됨)
Public 메서드정적 멤버 GetCustomizationVersion 지정된 문서와 연결되는 사용자 지정을 만드는 데 사용된 Microsoft Visual Studio Tools for Office Runtime의 버전을 반환합니다.
Public 메서드 GetHashCode 특정 형식에 대한 해시 함수 역할을 합니다. (Object에서 상속됨)
Public 메서드 GetType 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨)
Public 메서드정적 멤버 IsCacheEnabled 지정된 문서에 데이터 캐시가 있는지 여부를 나타내는 값을 가져옵니다.
Public 메서드정적 멤버 IsCustomized 지정된 문서에 Visual Studio 2010 Tools for Office Runtime을 사용하여 만든 사용자 지정이 있는지 여부를 나타내는 값을 가져옵니다.
Public 메서드정적 멤버 RemoveCustomization 문서에서 사용자 지정을 제거합니다.
Public 메서드 Save ServerDocument 클래스를 사용하여 문서의 변경 내용을 저장합니다.
Public 메서드 ToString 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨)

위쪽

명시적 인터페이스 구현

  이름 설명
명시적 인터페이스 구현Private 메서드 IDisposable.Dispose ServerDocument 에서 사용하는 모든 리소스를 해제합니다.

위쪽

설명

Excel 또는 Word가 설치되어 있지 않은 컴퓨터에서 문서 수준 사용자 지정의 특정 부분을 관리하려면 ServerDocument 클래스를 사용합니다.대개 Office 프로젝트가 아니라 콘솔 프로젝트 또는 Windows Forms 프로젝트와 같이 Office와 통합되지 않은 응용 프로그램에서 이 클래스를 사용합니다.

ServerDocument 클래스의 다음 멤버를 사용하여 일반적인 작업을 수행할 수 있습니다.

  • 서버에서 문서의 데이터 캐시에 있는 데이터에 액세스하고 이를 수정하려면 CachedData 속성을 사용합니다.

  • 프로그래밍 방식으로 사용자 지정을 문서에 연결하거나 문서에서 사용자 지정을 제거하려면 AddCustomizationRemoveCustomization 메서드를 사용합니다.

  • 문서와 연결된 배포 매니페스트의 URL에 액세스하거나 이를 변경하려면 DeploymentManifestUrl 속성을 사용합니다.

서로 다른 두 버전의 가지는 ServerDocument 클래스 런타임 Office 용 Visual Studio 2010 도구에서.사용해야 하는 버전은 이 클래스를 사용하려는 응용 프로그램의 대상 .NET Framework에 따라 달라집니다.

  • 대상 응용 프로그램의 .NET Framework 4 또는 .NET Framework 4.5, 사용의 Microsoft.VisualStudio.Tools.Applications.ServerDocument Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 어셈블리의 클래스에서에서.

  • .NET Framework 3.5를 대상으로 하는 응용 프로그램의 경우에는 Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 어셈블리의 Microsoft.VisualStudio.Tools.Applications.ServerDocument 클래스를 사용합니다.

자세한 내용은 ServerDocument 클래스를 사용하여 서버의 문서 관리을 참조하십시오.

사용할 생성자 선택

ServerDocument 클래스를 사용하여 문서의 캐시된 데이터 또는 배포 매니페스트 URL에 액세스하려면 ServerDocument 개체를 만들어야 합니다.

ServerDocument 생성자에는 다음 두 가지가 있습니다.

  • 메모리에 이미 열려 있는 문서에 액세스하는 데 사용할 수 있는 생성자

  • 디스크에 있는 문서에 액세스하는 데 사용할 수 있는 생성자

Bb514484.collapse_all(ko-kr,VS.110).gif메모리의 문서 액세스

메모리에 이미 열려 있는 문서에 액세스하려면 다음 생성자 중 하나를 사용합니다.

이러한 생성자는 바이트 배열이나 메모리의 문서를 나타내는 Stream을 받아들입니다.이는 HTTP 프로토콜을 사용하여 문서의 캐시된 데이터 또는 응용 프로그램 매니페스트를 대상으로 스트리밍하기 전에 수정하려는 경우에 유용합니다.이러한 생성자를 사용하려면 문서에 사용자 지정이 이미 있어야 합니다. 그렇지 않으면 이러한 생성자에서 CannotLoadManifestException 예외가 throw됩니다.

Bb514484.collapse_all(ko-kr,VS.110).gif디스크의 문서 액세스

디스크의 문서에 액세스하려면 다음 생성자 중 하나를 사용합니다.

이러한 생성자는 열려는 문서의 전체 경로를 받아들입니다.기본적으로 문서는 읽기/쓰기 권한으로 열립니다.읽기 전용 또는 쓰기 전용 권한으로 문서를 열려면 FileAccess 매개 변수가 있는 생성자를 사용합니다.

예제

다음 코드 예제에서는 지정된 문서를 로드한 다음 문서에 연결된 사용자 지정에 대한 배포 매니페스의 URL을 표시하는 새 ServerDocument를 만듭니다.

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

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

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

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

      또는

    • 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();
    }
}

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

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

기타 리소스

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

Office 솔루션의 응용 프로그램 및 배포 매니페스트

서버에 있는 문서의 데이터 액세스