Missing types using reflection on DLL

我是研究僧i 提交于 2019-12-13 07:12:58

问题


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?

来源:https://stackoverflow.com/questions/36625274/missing-types-using-reflection-on-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!