зеркало из 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
|
@ -150,10 +150,25 @@ namespace IKVM.Reflection
|
||||||
|
|
||||||
public static AssemblyName GetAssemblyName(string path)
|
public static AssemblyName GetAssemblyName(string path)
|
||||||
{
|
{
|
||||||
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
try
|
||||||
{
|
{
|
||||||
ModuleReader module = new ModuleReader(null, null, fs, path);
|
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
return module.Assembly.GetName();
|
{
|
||||||
|
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.stream = stream;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
Read();
|
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()
|
private void Read()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче