private bool LoadFromCompLibAssembly(string filePath) { bool flag; try { using (AssemblyMetaDataImport import = new AssemblyMetaDataImport(filePath)) { AssemblyName name = import.Name; this._identity = SystemUtils.GetDefinitionIdentityFromManagedAssembly(filePath); this._complibIdentity = (System.Deployment.Application.DefinitionIdentity) this.Identity.Clone(); AssemblyModule[] files = import.Files; AssemblyReference[] references = import.References; System.Deployment.Application.Manifest.File[] fileArray = new System.Deployment.Application.Manifest.File[files.Length + 1]; fileArray[0] = new System.Deployment.Application.Manifest.File(Path.GetFileName(filePath), 0L); for (int i = 0; i < files.Length; i++) { fileArray[i + 1] = new System.Deployment.Application.Manifest.File(files[i].Name, files[i].Hash, 0L); } this._files = fileArray; DependentAssembly[] assemblyArray = new DependentAssembly[references.Length]; for (int j = 0; j < references.Length; j++) { assemblyArray[j] = new DependentAssembly(new System.Deployment.Application.ReferenceIdentity(references[j].Name.ToString())); } this._dependentAssemblies = assemblyArray; this._manifestSourceFormat = System.Deployment.Application.Manifest.ManifestSourceFormat.CompLib; flag = true; } } catch (BadImageFormatException) { flag = false; } catch (COMException) { flag = false; } catch (SEHException) { flag = false; } catch (IOException) { flag = false; } return flag; }
private static System.Deployment.Application.DefinitionIdentity ExtractIdentityFromCompLibAssembly(string filePath) { System.Deployment.Application.DefinitionIdentity definitionIdentityFromManagedAssembly; Logger.AddMethodCall("AssemblyManifest.ExtractIdentityFromCompLibAssembly(" + filePath + ") called."); try { using (AssemblyMetaDataImport import = new AssemblyMetaDataImport(filePath)) { AssemblyName name = import.Name; definitionIdentityFromManagedAssembly = SystemUtils.GetDefinitionIdentityFromManagedAssembly(filePath); } } catch (BadImageFormatException) { definitionIdentityFromManagedAssembly = null; } catch (COMException) { definitionIdentityFromManagedAssembly = null; } catch (SEHException) { definitionIdentityFromManagedAssembly = null; } return definitionIdentityFromManagedAssembly; }