TypeLibConverter.ConvertAssemblyToTypeLib Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Converts an assembly to a COM type library.
public:
virtual System::Object ^ ConvertAssemblyToTypeLib(System::Reflection::Assembly ^ assembly, System::String ^ strTypeLibName, System::Runtime::InteropServices::TypeLibExporterFlags flags, System::Runtime::InteropServices::ITypeLibExporterNotifySink ^ notifySink);
public object ConvertAssemblyToTypeLib (System.Reflection.Assembly assembly, string strTypeLibName, System.Runtime.InteropServices.TypeLibExporterFlags flags, System.Runtime.InteropServices.ITypeLibExporterNotifySink notifySink);
abstract member ConvertAssemblyToTypeLib : System.Reflection.Assembly * string * System.Runtime.InteropServices.TypeLibExporterFlags * System.Runtime.InteropServices.ITypeLibExporterNotifySink -> obj
override this.ConvertAssemblyToTypeLib : System.Reflection.Assembly * string * System.Runtime.InteropServices.TypeLibExporterFlags * System.Runtime.InteropServices.ITypeLibExporterNotifySink -> obj
Public Function ConvertAssemblyToTypeLib (assembly As Assembly, strTypeLibName As String, flags As TypeLibExporterFlags, notifySink As ITypeLibExporterNotifySink) As Object
Parameters
- assembly
- Assembly
The assembly to convert.
- strTypeLibName
- String
The file name of the resulting type library.
- flags
- TypeLibExporterFlags
A TypeLibExporterFlags value indicating any special settings.
- notifySink
- ITypeLibExporterNotifySink
The ITypeLibExporterNotifySink interface implemented by the caller.
Returns
An object that implements the ITypeLib
interface.
Implements
Examples
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();
}
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;
}
}
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
End Class
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
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
Remarks
For more information on ITypeLib
, please see its existing documentation in the MSDN library.
Applies to
Surađujte s nama na GitHubu
Izvor za ovaj sadržaj možete pronaći na GitHubu, gdje možete stvarati i pregledavati probleme i zahtjeve za povlačenjem. Dodatne informacije potražite u našem vodiču za suradnike.