アセンブリを COM タイプ ライブラリに変換します。
Public Overridable Function ConvertAssemblyToTypeLib( _
ByVal assembly As Assembly, _ ByVal strTypeLibName As String, _ ByVal flags As TypeLibExporterFlags, _ ByVal notifySink As ITypeLibExporterNotifySink _) As Object Implements ITypeLibConverter.ConvertAssemblyToTypeLib
[C#]
public virtual object ConvertAssemblyToTypeLib(Assemblyassembly,stringstrTypeLibName,TypeLibExporterFlagsflags,ITypeLibExporterNotifySinknotifySink);
[C++]
public: virtual Object* ConvertAssemblyToTypeLib(Assembly* assembly,String* strTypeLibName,TypeLibExporterFlagsflags,ITypeLibExporterNotifySink* notifySink);
[JScript]
public function ConvertAssemblyToTypeLib(
assembly : Assembly,strTypeLibName : String,flags : TypeLibExporterFlags,notifySink : ITypeLibExporterNotifySink) : Object;
パラメータ
- assembly
変換対象のアセンブリ。 - strTypeLibName
結果として得られるタイプ ライブラリのファイル名。 - flags
任意の特別な設定を示す TypeLibExporterFlags 値。 - notifySink
呼び出し元によって実装されている ITypeLibExporterNotifySink インターフェイス。
戻り値
ITypeLib インターフェイスを実装するオブジェクト。
実装
ITypeLibConverter.ConvertAssemblyToTypeLib
解説
ITypeLib の詳細については、MSDN ライブラリの既存のドキュメントを参照してください。
使用例
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
[C#]
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;
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Runtime::InteropServices;
[ComImport,
GuidAttribute( S"00020406-0000-0000-C000-000000000046" ),
InterfaceTypeAttribute( ComInterfaceType::InterfaceIsIUnknown ),
ComVisible( false )]
public __gc __interface UCOMICreateITypeLib
{
void CreateTypeInfo();
void SetName();
void SetVersion();
void SetGuid();
void SetDocString();
void SetHelpFileName();
void SetHelpContext();
void SetLcid();
void SetLibFlags();
void SaveAllChanges();
};
public __gc class ConversionEventHandler : public ITypeLibExporterNotifySink
{
public:
void ReportEvent( ExporterEventKind eventKind, int eventCode, String* eventMsg )
{
// Handle the warning event here.
}
Object* ResolveRef( Assembly* a )
{
// Resolve the reference here and return a correct type library.
return 0;
}
};
int main()
{
Assembly* a = Assembly::LoadFrom( S"MyAssembly.dll" );
TypeLibConverter* converter = new TypeLibConverter();
ConversionEventHandler* eventHandler = new ConversionEventHandler();
UCOMICreateITypeLib* typeLib = dynamic_cast<UCOMICreateITypeLib*>(converter->ConvertAssemblyToTypeLib(
a, S"MyTypeLib.dll",static_cast<TypeLibExporterFlags>(0), eventHandler ));
typeLib->SaveAllChanges();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
TypeLibConverter クラス | TypeLibConverter メンバ | System.Runtime.InteropServices 名前空間