Exemple #1
0
        //# Creates a new assembly, inserting it into the provided project.
        public Assembly(Project project, string fileName)
        {
            try {
                m_project = project.CheckNotNull("project");
                m_peFile = new PEFile(this, fileName);

                var assemblyRowCount = MetadataTable.Assembly.RowCount(m_peFile);
                if (assemblyRowCount <= 0)
                {
                    throw new FileLoadException("Not an assembly", fileName);
                }
                if (assemblyRowCount > 1)
                {
                    throw new FileLoadException("Too many rows in the assembly table.");
                }

                m_modules = new ModuleCollection(this, m_peFile);
                project.Add(this);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Exemple #2
0
        public void Dispose()
        {
            if (m_peFile != null) {
                m_peFile.Dispose();
            }

            if (m_modules != null) {
                m_modules.Dispose();
            }

            m_modules = null;
            m_peFile = null;
            m_assemblyRow = null;
            m_project = null;
        }