本文介绍了列出DLL中的所有类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出DLL中的所有类,而不必加载依赖关系。我不想执行任何功能,我只想找出(有问题)什么类是在给定的DLL。那可能吗?我试过使用assembly.GetTypes()调用,但它失败,因为执行DLL的依赖。有没有其他方法来列出所有的公共类?

I would like to list all of the classes that are in a DLL without having to load the dependencies. I don't want to execute any functionality, I just want to find out (problematically) what classes are inside of a given DLL. Is that possible? I've tried using the assembly.GetTypes() call, but it fails because of dependencies for executing the DLL. Is there any other way to list all the public classes?

推荐答案

好吧,我找到了。此组合用于获取所有类的列表,而无需处理依赖关系:

Okay, I found it. This combination works to get a list of all classes without having to deal with the dependencies:

程序集assembly = Assembly.LoadFrom(filename);
Type [] types = assembly.GetTypes();

Assembly assembly = Assembly.LoadFrom(filename);Type[] types = assembly.GetTypes();

这篇关于列出DLL中的所有类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:14