TypeLibConverter.ConvertAssemblyToTypeLib-Methode
Konvertiert eine Assembly in eine COM-Typbibliothek.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Function ConvertAssemblyToTypeLib ( _
assembly As Assembly, _
strTypeLibName As String, _
flags As TypeLibExporterFlags, _
notifySink As ITypeLibExporterNotifySink _
) As Object
'Usage
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
Parameter
- assembly
Die zu konvertierende Assembly.
- strTypeLibName
Der Dateiname der resultierenden Typbibliothek.
- flags
Ein TypeLibExporterFlags-Wert, der alle speziellen Einstellungen angibt.
- notifySink
Die vom Aufrufer implementierte ITypeLibExporterNotifySink-Schnittstelle.
Rückgabewert
Ein Objekt, das die ITypeLib-Schnittstelle implementiert.
Hinweise
Weitere Informationen über ITypeLib finden Sie in der entsprechenden Dokumentation in der MSDN Library.
Beispiel
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-Sicherheit
- SecurityPermission für die Berechtigung zum Aufrufen von nicht verwaltetem Code. Sicherheitsaktion: Demand. Zugeordnete Enumeration: UnmanagedCode
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
TypeLibConverter-Klasse
TypeLibConverter-Member
System.Runtime.InteropServices-Namespace