зеркало из https://github.com/mono/ikvm-fork.git
Fixed AssemblyName.GetAssemblyName() to throw the proper exceptions (and by consequence Universe.LoadFile() now also throws the proper exceptions, module a race condition).
This commit is contained in:
Родитель
b790897da7
Коммит
f72c9f6cf8
|
@ -149,12 +149,27 @@ namespace IKVM.Reflection
|
|||
}
|
||||
|
||||
public static AssemblyName GetAssemblyName(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ModuleReader module = new ModuleReader(null, null, fs, path);
|
||||
if (module.Assembly == null)
|
||||
{
|
||||
throw new BadImageFormatException("Module does not contain a manifest");
|
||||
}
|
||||
return module.Assembly.GetName();
|
||||
}
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
throw new FileNotFoundException(x.Message, x);
|
||||
}
|
||||
catch (UnauthorizedAccessException x)
|
||||
{
|
||||
throw new FileNotFoundException(x.Message, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,11 @@ namespace IKVM.Reflection.Reader
|
|||
this.stream = stream;
|
||||
this.location = location;
|
||||
Read();
|
||||
this.assembly = assembly ?? new AssemblyReader(location, this);
|
||||
if (assembly == null && AssemblyTable.records.Length != 0)
|
||||
{
|
||||
assembly = new AssemblyReader(location, this);
|
||||
}
|
||||
this.assembly = assembly;
|
||||
}
|
||||
|
||||
private void Read()
|
||||
|
|
Загрузка…
Ссылка в новой задаче