Handle the case where not all types of an assembly can be loaded
This commit is contained in:
parent
7cd7afbfa6
commit
7a1154182b
@ -88,9 +88,14 @@ namespace Gst {
|
|||||||
// Add types with GTypeNameAttribute in TypeCache
|
// Add types with GTypeNameAttribute in TypeCache
|
||||||
if (result) {
|
if (result) {
|
||||||
AssemblyTypesInCache[asm.GetHashCode ()] = true;
|
AssemblyTypesInCache[asm.GetHashCode ()] = true;
|
||||||
Type[] ts = asm.GetTypes ();
|
Type[] ts;
|
||||||
|
try {
|
||||||
|
ts = asm.GetTypes ();
|
||||||
|
} catch (ReflectionTypeLoadException e) {
|
||||||
|
ts = e.Types;
|
||||||
|
}
|
||||||
foreach (Type t in ts) {
|
foreach (Type t in ts) {
|
||||||
if (t.IsDefined (typeof (GTypeNameAttribute), false)) {
|
if (t != null && t.IsDefined (typeof (GTypeNameAttribute), false)) {
|
||||||
GTypeNameAttribute gattr = (GTypeNameAttribute) Attribute.GetCustomAttribute (t, typeof (GTypeNameAttribute), false);
|
GTypeNameAttribute gattr = (GTypeNameAttribute) Attribute.GetCustomAttribute (t, typeof (GTypeNameAttribute), false);
|
||||||
TypeCache[gattr.TypeName] = t;
|
TypeCache[gattr.TypeName] = t;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user