Missing types using reflection on DLL

2019-09-17 23:41发布

问题:

I'm writing a program that uses reflection to look at a DLL, and obtain the table names/enums within.

After obtaining the assembly using the method "ReflectionOnlyLoadFrom" to avoid having to load all dependencies, I use the following code to grab the types:

try
{
    types = assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
    types = ex.Types.Where(p => p != null).ToArray();
}

This returns most of the types, but the ones I really need are not listed here.

The commonality between the missing types are that they all use Custom Attributes in the class (C#) as part of the data access layer. The table is defined above the class name in an attribute, and each property has an attribute above it to define it as a column in the DB.

Could custom attributes be causing an issue in relation to reflection, in that types aren't returned when they are present?