0x44); // IID_IMetaDataImport // This function will either use a given IMetadataEmitter for the ISymbolWriter2 // or it will make a new one based on the path that you provide. // In either case, you need to make sure that the metadata in the image file matches // the metadata in the symbols. public static ISymbolWriter2 GetWriterForFile(string pathModule, ref object emitter) { // If no emitter is provided, make one and return it. if (emitter == null) { // First get a dispenser object objDispenser; NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser); Debug.Assert(objDispenser != null, "Dispenser is null."); // Now get an emitter var dispenser = (IMetaDataDispenserPrivate) objDispenser; dispenser.OpenScope(pathModule, OPEN_WRITE, ref emitterIID, out emitter); } Debug.Assert(emitter != null, "Emitter is null."); // An emitter was provided, just use that one. ISymbolWriter2 writer = new SymbolWriter(); writer.Initialize(emitter, pathModule, false); return writer; }
0x44); // IID_IMetaDataImport // This function will either use a given IMetadataEmitter for the ISymbolWriter2 // or it will make a new one based on the path that you provide. // In either case, you need to make sure that the metadata in the image file matches // the metadata in the symbols. public static ISymbolWriter2 GetWriterForFile(string pathModule, ref object emitter) { // If no emitter is provided, make one and return it. if (emitter == null) { // First get a dispenser object objDispenser; NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser); Debug.Assert(objDispenser != null, "Dispenser is null."); // Now get an emitter var dispenser = (IMetaDataDispenserPrivate)objDispenser; dispenser.OpenScope(pathModule, OPEN_WRITE, ref emitterIID, out emitter); } Debug.Assert(emitter != null, "Emitter is null."); // An emitter was provided, just use that one. ISymbolWriter2 writer = new SymbolWriter(); writer.Initialize(emitter, pathModule, false); return(writer); }