Compartilhar via


Método TypeLibConverter.ConvertTypeLibToAssembly (Object, String, Int32, ITypeLibImporterNotifySink, Byte[], StrongNameKeyPair, Boolean)

 

Dica

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Converte uma biblioteca de tipo COM em um assembly.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (em mscorlib.dll)

Sintaxe

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public AssemblyBuilder ConvertTypeLibToAssembly(
    object typeLib,
    string asmFileName,
    int flags,
    ITypeLibImporterNotifySink notifySink,
    byte[] publicKey,
    StrongNameKeyPair keyPair,
    bool unsafeInterfaces
)
public:
[SecurityPermissionAttribute(SecurityAction::Demand, Flags = SecurityPermissionFlag::UnmanagedCode)]
virtual AssemblyBuilder^ ConvertTypeLibToAssembly(
    Object^ typeLib,
    String^ asmFileName,
    int flags,
    ITypeLibImporterNotifySink^ notifySink,
    array<unsigned char>^ publicKey,
    StrongNameKeyPair^ keyPair,
    bool unsafeInterfaces
) sealed
[<SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)>]
abstract ConvertTypeLibToAssembly : 
        typeLib:Object *
        asmFileName:string *
        flags:int *
        notifySink:ITypeLibImporterNotifySink *
        publicKey:byte[] *
        keyPair:StrongNameKeyPair *
        unsafeInterfaces:bool -> AssemblyBuilder
[<SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)>]
override ConvertTypeLibToAssembly : 
        typeLib:Object *
        asmFileName:string *
        flags:int *
        notifySink:ITypeLibImporterNotifySink *
        publicKey:byte[] *
        keyPair:StrongNameKeyPair *
        unsafeInterfaces:bool -> AssemblyBuilder
<SecurityPermissionAttribute(SecurityAction.Demand, Flags := SecurityPermissionFlag.UnmanagedCode)>
Public Function ConvertTypeLibToAssembly (
    typeLib As Object,
    asmFileName As String,
    flags As Integer,
    notifySink As ITypeLibImporterNotifySink,
    publicKey As Byte(),
    keyPair As StrongNameKeyPair,
    unsafeInterfaces As Boolean
) As AssemblyBuilder

Parâmetros

  • typeLib
    Type: System.Object

    O objeto que implementa a interface do ITypeLib.

  • asmFileName
    Type: System.String

    O nome do arquivo do assembly resultante.

  • publicKey
    Type: System.Byte[]

    Uma matriz byte que contém a chave pública.

  • unsafeInterfaces
    Type: System.Boolean

    Se true, as interfaces exigirão verificações de tempo de vinculação para a permissão UnmanagedCode. Se false, as interfaces exigirão verificações de tempo de execução que exigem percorrer uma pilha e são mais caras, mas ajudam a dar maior proteção.

Valor Retornado

Type: System.Reflection.Emit.AssemblyBuilder

Um objeto AssemblyBuilder que contém a biblioteca de tipos convertida.

Implementa

ITypeLibConverter.ConvertTypeLibToAssembly(Object, String, Int32, ITypeLibImporterNotifySink, Byte[], StrongNameKeyPair, Boolean)

Exceções

Exception Condition
ArgumentNullException

typeLib é null.

-ou-

asmFileName é null.

-ou-

notifySink é null.

ArgumentException

asmFileName é uma cadeia de caracteres vazia.

-ou-

asmFileName é maior que MAX_PATH.

InvalidOperationException

flags não é PrimaryInteropAssembly.

-ou-

publicKey e keyPair são null.

ReflectionTypeLoadException

Os metadados produzido têm erros que impedem o carregamento de qualquer tipo.

Comentários

Se você não quiser gerar um nome forte para o assembly, é válido para publicKey e keyPair ser null, contanto que flags não é igual a TypeLibImporterFlags.PrimaryInteropAssembly. Caso contrário, pelo menos um desses parâmetros deve ser especificado. Se publicKey é null, a chave pública no keyPair será definido em metadados do manifesto do assembly de destino e uma assinatura será gerada com base no conteúdo do assembly. Se keyPair é null, publicKey será definido em metadados do manifesto do assembly de destino e nenhuma assinatura será gerada. Especificar os dois parâmetros não é geralmente útil e pode resultar em uma assinatura inválida.

Para obter mais informações sobre ITypeLib, consulte sua documentação existente na biblioteca MSDN.

Segurança

SecurityPermission

for permission to call unmanaged code.

Security Action: Demand.

Associated Enumeration: F:System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode

Informações de Versão

.NET Framework
Disponível desde 1.1

Confira Também

ConvertTypeLibToAssembly Sobrecarga
Classe TypeLibConverter
Namespace System.Runtime.InteropServices
Atributos para importar bibliotecas de tipos em assemblies de interoperabilidade

Retornar ao início