다음을 통해 공유


ClientBuildManagerParameter.StrongNameKeyContainer 속성

정의

컴파일하는 동안 사용되는 키 컨테이너를 가져오거나 설정합니다.

public:
 property System::String ^ StrongNameKeyContainer { System::String ^ get(); void set(System::String ^ value); };
public string StrongNameKeyContainer { get; set; }
member this.StrongNameKeyContainer : string with get, set
Public Property StrongNameKeyContainer As String

속성 값

키 컨테이너 값의 String입니다.

예제

다음 코드 예제는 있는 코드 예제와 비슷한는 ClientBuildManager 결과 어셈블리에 제공된 된 키 컨테이너에 따라 강력한 이름을 가진 한다는 클래스 개요입니다. 이 따라 제공 된 미리 컴파일합니다 PrecompilationFlags 값입니다.


using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Compilation;
using System.Security;
using System.Security.Permissions;

namespace PrecompBuildSystem
{
    [PermissionSet(SecurityAction.Demand, Unrestricted = true)]
    public class PrecompBuilder
    {
        private static ClientBuildManager builder;
        private static String _vPath;	// Virtual
        private static String _pPath;	// Physical
        private static String _tPath;	// Target
        private static PrecompilationFlags _flags;
        private static ClientBuildManagerParameter _cbmParameter;
        private static String _keyContainer;

        public static void Main(string[] args)
        {
            // Check arguments.
            if (ValidateAndSetArguments(args))
            {
                _cbmParameter = new ClientBuildManagerParameter();
                _cbmParameter.PrecompilationFlags = _flags;
                _cbmParameter.StrongNameKeyContainer = _keyContainer;

                builder = new
                        ClientBuildManager(_vPath, _pPath, _tPath, _cbmParameter);
                // Pre-compile.
                if (Precompiler())
                {
                    Console.Write("Build succeeded. Result is at " + _tPath + ".");
                }
            }
        }

        private static bool ValidateAndSetArguments(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    _vPath = args[0];
                }
                else
                {
                    _vPath = (string)AppSettingsExpressionBuilder.GetAppSetting
                        ("virtualDirectory");
                }

                if (args.Length > 1)
                {
                    _pPath = args[1];
                }
                else
                {
                    _pPath = (string)AppSettingsExpressionBuilder.GetAppSetting
                        ("physicalDirectory");
                }

                if (args.Length > 2)
                {
                    _tPath = args[2];
                }
                else
                {
                    _tPath = (string)AppSettingsExpressionBuilder.GetAppSetting
                        ("targetDirectory");
                }

                if (args.Length > 3)
                {
                    string[] precompFlags = args[3].Split('|');
                    foreach (string flag in precompFlags)
                    {
                        _flags |= (PrecompilationFlags)Enum.Parse
                            (typeof(PrecompilationFlags), flag.Trim());
                    }
                }
                else
                {
                    _flags = PrecompilationFlags.Clean |
                        PrecompilationFlags.ForceDebug;
                }

                if (args.Length > 4)
                {
                    _keyContainer = args[4];
                }

                return true;
            }
            catch (Exception e)
            {
                OutputErrorList(e);
            }
            return false;
        }
        private static void OutputErrorList(Exception e)
        {
            Console.Write("Error: " + e.Message);
        }

        private static bool Precompiler()
        {
            try
            {
                builder.PrecompileApplication();

                // The precompilation was successful.
                return true;
            }
            catch (Exception e)
            {
                OutputErrorList(e);
            }

            // The precompilation failed.
            return false;
        }
    }
}

Imports System.Web.Compilation
Imports System.Security
Imports System.Security.Permissions
Namespace PrecompBuildSystem

    <PermissionSet(SecurityAction.Demand, Unrestricted:=true)> _
    Public Class PrecompBuilder
        Private Shared builder As ClientBuildManager
        Private Shared _vPath As String ' Virtual
        Private Shared _pPath As String ' Physical
        Private Shared _tPath As String ' Target
        Private Shared _flags As PrecompilationFlags
        Private Shared _cbmParameter As ClientBuildManagerParameter
        Private Shared _keyContainer As String

        Public Shared Sub Main(ByVal args As String())
            ' Check arguments.
            If (ValidateAndSetArguments(args)) Then

                _cbmParameter = New ClientBuildManagerParameter()
                _cbmParameter.PrecompilationFlags = _flags
                _cbmParameter.StrongNameKeyContainer = _keyContainer

                builder = New ClientBuildManager(_vPath, _pPath, _tPath, _cbmParameter)
                ' Pre-compile.
                If (Precompiler()) Then
                    Console.Write("Build succeeded. Result is at " + _tPath + ".")
                End If
            End If
        End Sub

        Private Shared Function ValidateAndSetArguments(ByVal args As String()) As Boolean
            Try
                If (args.Length > 0) Then
                    _vPath = args(0)
                Else
                    _vPath = AppSettingsExpressionBuilder.GetAppSetting("virtualDirectory")
                End If

                If (args.Length > 1) Then
                    _pPath = args(1)
                Else
                    _pPath = AppSettingsExpressionBuilder.GetAppSetting("physicalDirectory")
                End If

                If (args.Length > 2) Then
                    _tPath = args(2)
                Else
                    _tPath = AppSettingsExpressionBuilder.GetAppSetting("targetDirectory")
                End If

                If (args.Length > 3) Then
                    Dim precompFlags As String()
                    precompFlags = args(3).Split("|"c)
                    For Each flag As String In precompFlags
                        _flags = _flags Or [Enum].Parse(GetType(PrecompilationFlags), flag.Trim())
                    Next
                Else
                    _flags = PrecompilationFlags.Clean Or PrecompilationFlags.ForceDebug
                End If

                If (args.Length > 4) Then
                    _keyContainer = args(4)
                End If
                Return True
            Catch e As Exception
                OutputErrorList(e)
            End Try
            Return False
        End Function

        Private Shared Sub OutputErrorList(ByVal e As Exception)
            Console.Write("Error: " + e.Message)
        End Sub

        Private Shared Function Precompiler() As Boolean
            Try
                builder.PrecompileApplication()

                ' The precompilation was successful.
                Return True
            Catch e As Exception
                OutputErrorList(e)
            End Try

            ' The precompilation failed.
            Return False
        End Function
    End Class
End Namespace

설명

중 하나는 StrongNameKeyContainer 속성 또는 StrongNameKeyFile 속성 강력한 이름의 어셈블리를 만드는 값이 할당 됩니다. 값이 모두 강력한 이름의 어셈블리를 만드는 설정할 필요가 없습니다.

적용 대상

추가 정보