Esempio n. 1
0
        public SymbolWriter(string binaryFile, string pdbFile)
        {
            Contract.Requires(binaryFile != null);
            Contract.Requires(pdbFile != null);
            IntPtr importer = IntPtr.Zero;

            try {
                object dispenser;
                OLE32.CoCreateInstance(ref XGuid.dispenserClassID, null, 1, ref XGuid.dispenserIID, out dispenser);
                object pUnknown;
                ((IMetaDataDispenserSubset)dispenser).OpenScope(binaryFile, 0, ref XGuid.importerIID, out pUnknown);
                importer = Marshal.GetComInterfaceForObject(pUnknown, typeof(IMetadataImport));

                object writer2;
                OLE32.CoCreateInstance(ref XGuid.symWriterClassID, null, 1, ref XGuid.symWriterIID, out writer2);
                writer = (ISymUnmanagedWriter2)writer2;
                writer.Initialize(importer, pdbFile, null, true);
            }
            catch (Exception x) {
                Console.WriteLine(x.Message);
            }
            finally {
                if (importer != IntPtr.Zero)
                {
                    Marshal.Release(importer);
                }
            }
        }
Esempio n. 2
0
        public SymbolWriter(string binaryFile, string pdbFile)
        {
            Contract.Requires(binaryFile != null);
            Contract.Requires(pdbFile != null);
            IntPtr importer = IntPtr.Zero;

            try {
              object dispenser;
              OLE32.CoCreateInstance(ref XGuid.dispenserClassID, null, 1, ref XGuid.dispenserIID, out dispenser);
              object pUnknown;
              ((IMetaDataDispenserSubset)dispenser).OpenScope(binaryFile, 0, ref XGuid.importerIID, out pUnknown);
            importer = Marshal.GetComInterfaceForObject(pUnknown, typeof(IMetadataImport));

              object writer2;
              OLE32.CoCreateInstance(ref XGuid.symWriterClassID, null, 1, ref XGuid.symWriterIID, out writer2);
            writer = (ISymUnmanagedWriter2)writer2;
            writer.Initialize(importer, pdbFile, null, true);
              }
              catch (Exception x) {
            Console.WriteLine(x.Message);
              }
              finally {
            if (importer != IntPtr.Zero)
              Marshal.Release(importer);
              }
        }
Esempio n. 3
0
 private void InitWriter()
 {
     if (symUnmanagedWriter == null)
     {
         string fileName = System.IO.Path.ChangeExtension(moduleBuilder.FullyQualifiedName, ".pdb");
         // pro-actively delete the .pdb to get a meaningful IOException, instead of COMInteropException if the file can't be overwritten (or is corrupt, or who knows what)
         System.IO.File.Delete(fileName);
         symUnmanagedWriter = new ISymUnmanagedWriter2();
         symUnmanagedWriter.Initialize(this, fileName, null, true);
     }
 }
 public override void Initialize(Metadata metadata)
 {
     if (isDeterministic)
     {
         ((ISymUnmanagedWriter6)writer).InitializeDeterministic(new MDEmitter(metadata), new StreamIStream(pdbStream));
     }
     else
     {
         writer.Initialize(new MDEmitter(metadata), pdbFileName, new StreamIStream(pdbStream), true);
     }
 }
Esempio n. 5
0
        public void SetMetadataEmitter(object metadataEmitter)
        {
            ISymUnmanagedWriter2 symWriter = null;
            Type t = Type.GetTypeFromProgID("CorSymWriter_SxS", false);

            if (t != null)
            {
                symWriter = (ISymUnmanagedWriter2)Activator.CreateInstance(t);
                symWriter.Initialize(metadataEmitter, this.fileName, null, true);
            }
            this.symWriter = symWriter;
        }
Esempio n. 6
0
        /// <summary>
        /// Initialize's instances of <c>ISymUnmanagedReader</c> and <c>ISymUnmanagedWriter</c> interfaces.
        /// The first is used to read symbols from the new assembly and second for writing part of it with tokens
        /// relative to the old assembly.
        /// </summary>
        /// <param name="oldEmitter"><c>IMetaDataEmit</c> instance relative to the old running assembly.</param>
        /// <param name="newImporter"><c>IMetaDataImport</c> instance relative to the new background-compiled assembly.</param>
        public void Initialize(IMetaDataEmit oldEmitter, IMetaDataImport newImporter)
        {
            DeltaPDBPath = manager.ResourceManager.TemporaryPath + "temp";
            IntPtr pFilename  = Marshal.StringToCoTaskMemUni(manager.ResourceManager.NewAssemblyPath);
            IntPtr pFilename2 = Marshal.StringToCoTaskMemUni(DeltaPDBPath + ".exe");
            IntPtr pPath      = Marshal.StringToCoTaskMemUni("");

            try
            {
                mReader.Initialize(newImporter, pFilename, pPath, null);
                mWriter.Initialize(oldEmitter, pFilename2, stream, 0);
                State = WriterState.Building;
            }
            catch (System.Exception e)
            {
                throw new TranslatingException(DeltaPDBPath + ";" + e.Message);
            }
            finally
            {
                Marshal.FreeCoTaskMem(pFilename2);
                Marshal.FreeCoTaskMem(pFilename);
                Marshal.FreeCoTaskMem(pPath);
            }
        }
Esempio n. 7
0
 public void Initialize(object emitter, string filename, bool fFullBuild)
 {
     m_writer.Initialize(emitter, filename, null, fFullBuild);
 }
Esempio n. 8
0
 public void Initialize(IntPtr emitter, string filename, bool fFullBuild)
 {
     writer.Initialize(emitter, filename, null, fFullBuild);
 }
Esempio n. 9
0
 private void InitWriter()
 {
     if (symUnmanagedWriter == null)
     {
         string fileName = System.IO.Path.ChangeExtension(moduleBuilder.FullyQualifiedName, ".pdb");
         // pro-actively delete the .pdb to get a meaningful IOException, instead of COMInteropException if the file can't be overwritten (or is corrupt, or who knows what)
         System.IO.File.Delete(fileName);
         symUnmanagedWriter = new ISymUnmanagedWriter2();
         symUnmanagedWriter.Initialize(this, fileName, null, true);
     }
 }
Esempio n. 10
0
 public void SetMetadataEmitter(object metadataEmitter)
 {
     ISymUnmanagedWriter2 symWriter = null;
       Type t = Type.GetTypeFromProgID("CorSymWriter_SxS", false);
       if (t != null) {
     symWriter = (ISymUnmanagedWriter2)Activator.CreateInstance(t);
     symWriter.Initialize(metadataEmitter, this.fileName, null, true);
       }
       this.symWriter = symWriter;
 }