Assembly ITypeLibImporterNotifySink.ResolveRef(Object typeLib) { try { string assem = importer.GetComReference((UCOMITypeLib)typeLib); if (assem != null) { importer.AddReferencedAssembly(assem); } Assembly a = importer.FindRCW((UCOMITypeLib)typeLib); if (a != null) { return(a); } // Generate the RCW for the typelib. We have to go through the motions of this anyway, // because there is no easy way to find the dependent references for this typelib. // try { string tlbName = Marshal.GetTypeLibName((UCOMITypeLib)typeLib); string rcwName = Path.Combine(options.outputDirectory, tlbName + ".dll"); Debug.WriteLineIf(AxWrapperGen.AxWrapper.Enabled, "\tConverting recursive TypeLib Name: " + tlbName + " in " + rcwName); if (importer.GetReferencedAssembly(rcwName) != null) { Debug.WriteLineIf(AxWrapperGen.AxWrapper.Enabled, "\t\tFound RCW in referenced assembly list at " + rcwName); return(importer.GetCopiedAssembly(rcwName, false, false)); } // Create the TypeLibConverter. TypeLibConverter tlbConv = new TypeLibConverter(); // Try to locate the primary interop assembly first. // a = importer.GetPrimaryInteropAssembly((UCOMITypeLib)typeLib, tlbConv); if (a != null) { return(a); } else { // Convert the typelib. AssemblyBuilder asmBldr = tlbConv.ConvertTypeLibToAssembly(typeLib, rcwName, (TypeLibImporterFlags)0, new ImporterCallback(importer), options.publicKey, options.keyPair, null, null); if (assem == null) { // Save the assembly to the disk only if we did not find it already on the reference list. // Debug.WriteLineIf(AxWrapperGen.AxWrapper.Enabled, "\t\tGenerated RCW at " + rcwName); string rcwAssem = importer.SaveAssemblyBuilder((UCOMITypeLib)typeLib, asmBldr, rcwName); importer.AddRCW((UCOMITypeLib)typeLib, asmBldr); return(asmBldr); } else { Debug.WriteLineIf(AxWrapperGen.AxWrapper.Enabled, "\t\tFound COM Reference at " + assem); return(importer.GetCopiedAssembly(assem, false, false)); } } } catch (Exception) { return(null); } } finally { Marshal.ReleaseComObject(typeLib); } }