public void Dispose() { m_assembly = null; m_metadataTableHeader = null; m_pData = null; m_fileSize = 0; m_peHeader = null; m_optionalHeader = null; m_clrHeader = null; m_streams = null; m_fullPath = null; if (m_tables != null) { for (var i = 0; i < m_tables.Length; ++i) { m_tables[i] = null; } m_tables = null; } if (m_memoryMap != null) { m_memoryMap.Dispose(); m_memoryMap = null; } }
public PEFile(Assembly assembly, String fileName) { try { m_assembly = assembly.CheckNotNull("assembly"); m_fullPath = new FileInfo(fileName).FullName; m_memoryMap = NativePlatform.Default.MemoryMapFile(fileName); m_pData = (byte *)m_memoryMap.Data; m_fileSize = m_memoryMap.Size; if (!(Verify())) { throw new FileLoadException("The file is not a valid managed executable.", fileName); } } catch (Exception ex) { Dispose(); if (ex is FileLoadException) { throw; } throw new FileLoadException("Unable to load assembly", fileName, ex); } }