/* * This private function provides implementation for the two public versions. * searchPath is a simicolon-delimited list of paths on which to search for pathModule. * If searchPath is null, pathModule must be a full path to the assembly. */ private static ISymbolReader GetReaderForFile(SymbolBinder binder, string pathModule, string searchPath) { // First create the Metadata dispenser. object objDispenser; NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser); // Now open an Importer on the given filename. We'll end up passing this importer straight // through to the Binder. object objImporter; var dispenser = (IMetaDataDispenserPrivate)objDispenser; dispenser.OpenScope(pathModule, OPEN_READ, ref importerIID, out objImporter); IntPtr importerPtr = IntPtr.Zero; ISymbolReader reader; try { // This will manually AddRef the underlying object, so we need to be very careful to Release it. importerPtr = Marshal.GetComInterfaceForObject(objImporter, typeof(IMetadataImportPrivateComVisible)); reader = binder.GetReader(importerPtr, pathModule, searchPath); } finally { if (importerPtr != IntPtr.Zero) { Marshal.Release(importerPtr); } } return(reader); }
/* * This private function provides implementation for the two public versions. * searchPath is a simicolon-delimited list of paths on which to search for pathModule. * If searchPath is null, pathModule must be a full path to the assembly. */ private static ISymbolReader GetReaderForFile(SymbolBinder binder, string pathModule, string searchPath) { // First create the Metadata dispenser. object objDispenser; NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser); // Now open an Importer on the given filename. We'll end up passing this importer straight // through to the Binder. object objImporter; var dispenser = (IMetaDataDispenserPrivate) objDispenser; dispenser.OpenScope(pathModule, OPEN_READ, ref importerIID, out objImporter); IntPtr importerPtr = IntPtr.Zero; ISymbolReader reader; try { // This will manually AddRef the underlying object, so we need to be very careful to Release it. importerPtr = Marshal.GetComInterfaceForObject(objImporter, typeof (IMetadataImportPrivateComVisible)); reader = binder.GetReader(importerPtr, pathModule, searchPath); } finally { if (importerPtr != IntPtr.Zero) { Marshal.Release(importerPtr); } } return reader; }