Im currently trying to use the method TypeLibConverter.ConvertTypeLibToAssembly. Im using the c# example found at http://msdn2.microsoft.com/en-us/library/k9w7de3e.aspx.
The example works for building a single dll, however the typelib i am converting has multiple references within it which need to be resolved. When the ConversionEventHandler ResolveRef(object typelib) method is called when a reference is found im passed the object typelib (which i dont know what to do with). How do i resolve reference and return a correct assembly
Any help is appreciated.
Code Example
using System; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; public class App { private enum RegKind { RegKind_Default = 0, RegKind_Register = 1, RegKind_None = 2 } [ DllImport( "oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false )] private static extern void LoadTypeLibEx( String strTypeLibName, RegKind regKind, [ MarshalAs( UnmanagedType.Interface )] out Object typeLib ); public static void Main() { Object typeLib; LoadTypeLibEx( "Somedll.dll", RegKind.RegKind_None, out typeLib ); if( typeLib == null ) { Console.WriteLine( "LoadTypeLibEx failed." ); return; } TypeLibConverter converter = new TypeLibConverter(); ConversionEventHandler eventHandler = new ConversionEventHandler(); AssemblyBuilder asm = converter.ConvertTypeLibToAssembly( typeLib, "Interop.Somedll.dll", 0, eventHandler, null, null, null, null ); asm.Save( "Interop.Somedll.dll" ); } } public class ConversionEventHandler : ITypeLibImporterNotifySink { public void ReportEvent( ImporterEventKind eventKind, int eventCode, string eventMsg ) { // handle warning event here... } public Assembly ResolveRef( object typeLib ) { // resolve reference here and return a correct assembly...
//This is where im not sure how to do it
return null; } }

How to resolve typelib references when using TypeLibConverter.ConvertTypeLibToAssembly