}
name.HashAlgorithm = (AssemblyHashAlgorithm)rec.HashAlgId;
name.CodeBase = this.CodeBase;
+ PortableExecutableKinds peKind;
+ ImageFileMachine machine;
+ manifestModule.GetPEKind(out peKind, out machine);
+ switch (machine)
+ {
+ case ImageFileMachine.I386:
+ // FXBUG we copy the .NET bug that Preferred32Bit implies x86
+ if ((peKind & (PortableExecutableKinds.Required32Bit | PortableExecutableKinds.Preferred32Bit)) != 0)
+ {
+ name.ProcessorArchitecture = ProcessorArchitecture.X86;
+ }
+ else if ((rec.Flags & 0x70) == 0x70)
+ {
+ // it's a reference assembly
+ name.ProcessorArchitecture = ProcessorArchitecture.None;
+ }
+ else
+ {
+ name.ProcessorArchitecture = ProcessorArchitecture.MSIL;
+ }
+ break;
+ case ImageFileMachine.IA64:
+ name.ProcessorArchitecture = ProcessorArchitecture.IA64;
+ break;
+ case ImageFileMachine.AMD64:
+ name.ProcessorArchitecture = ProcessorArchitecture.Amd64;
+ break;
+ case ImageFileMachine.ARM:
+ name.ProcessorArchitecture = ProcessorArchitecture.Arm;
+ break;
+ }
name.RawFlags = (AssemblyNameFlags)rec.Flags;
return name;
}
return type;
}
+ internal override Type FindTypeIgnoreCase(TypeName lowerCaseName)
+ {
+ Type type = manifestModule.FindTypeIgnoreCase(lowerCaseName);
+ for (int i = 0; type == null && i < externalModules.Length; i++)
+ {
+ if ((manifestModule.File.records[i].Flags & ContainsNoMetaData) == 0)
+ {
+ type = GetModule(i).FindTypeIgnoreCase(lowerCaseName);
+ }
+ }
+ return type;
+ }
+
public override string ImageRuntimeVersion
{
get { return manifestModule.__ImageRuntimeVersion; }
{
return externalModules[index];
}
- // TODO add ModuleResolve event
- string location = Path.Combine(Path.GetDirectoryName(this.location), manifestModule.GetString(manifestModule.File.records[index].Name));
- return LoadModule(index, null, location);
+ return LoadModule(index, null, manifestModule.GetString(manifestModule.File.records[index].Name));
}
- private Module LoadModule(int index, byte[] rawModule, string location)
+ private Module LoadModule(int index, byte[] rawModule, string name)
{
+ string location = name == null ? null : Path.Combine(Path.GetDirectoryName(this.location), name);
if ((manifestModule.File.records[index].Flags & ContainsNoMetaData) != 0)
{
return externalModules[index] = new ResourceModule(manifestModule, index, location);
{
if (rawModule == null)
{
- rawModule = File.ReadAllBytes(location);
+ try
+ {
+ rawModule = File.ReadAllBytes(location);
+ }
+ catch (FileNotFoundException)
+ {
+ if (resolvers != null)
+ {
+ ResolveEventArgs arg = new ResolveEventArgs(name, this);
+ foreach (ModuleResolveEventHandler resolver in resolvers)
+ {
+ Module module = resolver(this, arg);
+ if (module != null)
+ {
+ return module;
+ }
+ }
+ }
+ if (universe.MissingMemberResolution)
+ {
+ return externalModules[index] = new MissingModule(this);
+ }
+ throw;
+ }
}
return externalModules[index] = new ModuleReader(this, manifestModule.universe, new MemoryStream(rawModule), location);
}
return manifestModule.__GetReferencedAssemblies();
}
- public override AssemblyNameFlags __AssemblyFlags
+ protected override AssemblyNameFlags GetAssemblyFlags()
{
- get { return (AssemblyNameFlags)manifestModule.AssemblyTable.records[0].Flags; }
+ return (AssemblyNameFlags)manifestModule.AssemblyTable.records[0].Flags;
}
internal string Name
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
{
- return manifestModule.GetCustomAttributes(0x20000001, attributeType);
+ return CustomAttributeData.GetCustomAttributesImpl(null, manifestModule, 0x20000001, attributeType) ?? CustomAttributeData.EmptyList;
}
}
}