TypeLibConverter.ConvertAssemblyToTypeLib 메서드
어셈블리를 COM 형식 라이브러리로 변환합니다.
네임스페이스: System.Runtime.InteropServices
어셈블리: mscorlib(mscorlib.dll)
구문
‘선언
Public Function ConvertAssemblyToTypeLib ( _
assembly As Assembly, _
strTypeLibName As String, _
flags As TypeLibExporterFlags, _
notifySink As ITypeLibExporterNotifySink _
) As Object
‘사용 방법
Dim instance As TypeLibConverter
Dim assembly As Assembly
Dim strTypeLibName As String
Dim flags As TypeLibExporterFlags
Dim notifySink As ITypeLibExporterNotifySink
Dim returnValue As Object
returnValue = instance.ConvertAssemblyToTypeLib(assembly, strTypeLibName, flags, notifySink)
public Object ConvertAssemblyToTypeLib (
Assembly assembly,
string strTypeLibName,
TypeLibExporterFlags flags,
ITypeLibExporterNotifySink notifySink
)
public:
virtual Object^ ConvertAssemblyToTypeLib (
Assembly^ assembly,
String^ strTypeLibName,
TypeLibExporterFlags flags,
ITypeLibExporterNotifySink^ notifySink
) sealed
public final Object ConvertAssemblyToTypeLib (
Assembly assembly,
String strTypeLibName,
TypeLibExporterFlags flags,
ITypeLibExporterNotifySink notifySink
)
public final function ConvertAssemblyToTypeLib (
assembly : Assembly,
strTypeLibName : String,
flags : TypeLibExporterFlags,
notifySink : ITypeLibExporterNotifySink
) : Object
매개 변수
- assembly
변환할 어셈블리입니다.
- strTypeLibName
결과로 만들어지는 형식 라이브러리의 파일 이름입니다.
- flags
특별한 설정을 나타내는 TypeLibExporterFlags 값입니다.
- notifySink
호출자가 구현한 ITypeLibExporterNotifySink 인터페이스입니다.
반환 값
ITypeLib 인터페이스를 구현하는 개체입니다.
설명
ITypeLib에 대한 자세한 내용은 MSDN library의 기존 설명서를 참조하십시오.
예제
Imports System
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Runtime.InteropServices
<ComImport(), GuidAttribute("00020406-0000-0000-C000-000000000046"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown), ComVisible(False)> _
Public Interface UCOMICreateITypeLib
Sub CreateTypeInfo()
Sub SetName()
Sub SetVersion()
Sub SetGuid()
Sub SetDocString()
Sub SetHelpFileName()
Sub SetHelpContext()
Sub SetLcid()
Sub SetLibFlags()
Sub SaveAllChanges()
End Interface 'UCOMICreateITypeLib
Public Class App
Public Shared Sub Main()
Dim asm As [Assembly] = [Assembly].LoadFrom("MyAssembly.dll")
Dim converter As New TypeLibConverter()
Dim eventHandler As New ConversionEventHandler()
Dim typeLib As UCOMICreateITypeLib = CType(converter.ConvertAssemblyToTypeLib(asm, "MyTypeLib.dll", 0, eventHandler), UCOMICreateITypeLib)
typeLib.SaveAllChanges()
End Sub 'Main
End Class 'App
Public Class ConversionEventHandler
Implements ITypeLibExporterNotifySink
Public Sub ReportEvent(ByVal eventKind As ExporterEventKind, ByVal eventCode As Integer, ByVal eventMsg As String) Implements ITypeLibExporterNotifySink.ReportEvent
' Handle the warning event here.
End Sub 'ReportEvent
Public Function ResolveRef(ByVal asm As [Assembly]) As [Object] Implements ITypeLibExporterNotifySink.ResolveRef
' Resolve the reference here and return a correct type library.
Return Nothing
End Function 'ResolveRef
End Class 'ConversionEventHandler
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
[ComImport,
GuidAttribute( "00020406-0000-0000-C000-000000000046" ),
InterfaceTypeAttribute( ComInterfaceType.InterfaceIsIUnknown ),
ComVisible( false )]
public interface UCOMICreateITypeLib
{
void CreateTypeInfo();
void SetName();
void SetVersion();
void SetGuid();
void SetDocString();
void SetHelpFileName();
void SetHelpContext();
void SetLcid();
void SetLibFlags();
void SaveAllChanges();
}
public class App
{
public static void Main()
{
Assembly asm = Assembly.LoadFrom( "MyAssembly.dll" );
TypeLibConverter converter = new TypeLibConverter();
ConversionEventHandler eventHandler = new ConversionEventHandler();
UCOMICreateITypeLib typeLib = (UCOMICreateITypeLib)converter.ConvertAssemblyToTypeLib( asm, "MyTypeLib.dll", 0, eventHandler );
typeLib.SaveAllChanges();
}
}
public class ConversionEventHandler : ITypeLibExporterNotifySink
{
public void ReportEvent( ExporterEventKind eventKind, int eventCode, string eventMsg )
{
// Handle the warning event here.
}
public Object ResolveRef( Assembly asm )
{
// Resolve the reference here and return a correct type library.
return null;
}
}
using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Runtime::InteropServices;
[ComImport,
GuidAttribute("00020406-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType::InterfaceIsIUnknown),
ComVisible(false)]
interface class UCOMICreateITypeLib
{
void CreateTypeInfo();
void SetName();
void SetVersion();
void SetGuid();
void SetDocString();
void SetHelpFileName();
void SetHelpContext();
void SetLcid();
void SetLibFlags();
void SaveAllChanges();
};
public ref class ConversionEventHandler: public ITypeLibExporterNotifySink
{
public:
virtual void ReportEvent( ExporterEventKind eventKind, int eventCode, String^ eventMsg )
{
// Handle the warning event here.
}
virtual Object^ ResolveRef( Assembly^ a )
{
// Resolve the reference here and return a correct type library.
return nullptr;
}
};
int main()
{
Assembly^ a = Assembly::LoadFrom( "MyAssembly.dll" );
TypeLibConverter^ converter = gcnew TypeLibConverter;
ConversionEventHandler^ eventHandler = gcnew ConversionEventHandler;
UCOMICreateITypeLib^ typeLib = dynamic_cast<UCOMICreateITypeLib^>(converter->ConvertAssemblyToTypeLib( a, "MyTypeLib.dll", static_cast<TypeLibExporterFlags>(0), eventHandler ));
typeLib->SaveAllChanges();
}
import System.*;
import System.Reflection.*;
import System.Reflection.Emit.*;
import System.Runtime.InteropServices.*;
/** @attribute ComImport()
@attribute GuidAttribute("00020406-0000-0000-C000-000000000046")
@attribute InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)
@attribute ComVisible(false)
*/
public interface UCOMICreateITypeLib
{
void CreateTypeInfo();
void SetName();
void SetVersion();
void SetGuid();
void SetDocString();
void SetHelpFileName();
void SetHelpContext();
void SetLcid();
void SetLibFlags();
void SaveAllChanges();
} //UCOMICreateITypeLib
public class App
{
public static void main(String[] args)
{
Assembly asm = Assembly.LoadFrom("MyAssembly.dll");
TypeLibConverter converter = new TypeLibConverter();
ConversionEventHandler eventHandler = new ConversionEventHandler();
UCOMICreateITypeLib typeLib = ((UCOMICreateITypeLib)(converter.
ConvertAssemblyToTypeLib(asm, "MyTypeLib.dll",
(TypeLibExporterFlags) 0, eventHandler)));
typeLib.SaveAllChanges();
} //main
} //App
public class ConversionEventHandler implements ITypeLibExporterNotifySink
{
public void ReportEvent(ExporterEventKind eventKind,
int eventCode, String eventMsg)
{
// Handle the warning event here.
} //ReportEvent
public Object ResolveRef(Assembly asm)
{
// Resolve the reference here and return a correct type library.
return null ;
} //ResolveRef
} //ConversionEventHandler
.NET Framework 보안
- SecurityPermission 비관리 코드를 호출하는 데 필요한 권한입니다. 보안 동작: 요청 연관된 열거형: UnmanagedCode
플랫폼
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
참고 항목
참조
TypeLibConverter 클래스
TypeLibConverter 멤버
System.Runtime.InteropServices 네임스페이스