如何在C#中获取项目引用列表 [英] How to get a list of Project References in C#
问题描述
我还是一个菜鸟。
我有一个加载插件的主应用程序。我想验证在启动插件之前运行插件所需的所有Reference DLL都存在于Main App目录中,如果没有,请从某个位置下载它。
我努力的方法是从插件中获取引用列表。
我试过这个:
List< assemblyname> a = Assembly.GetEntryAssembly()。GetReferencedAssemblies()。ToList();
但问题是,这只给了我在那个阶段加载的程序集。我需要一个应用程序中引用的所有程序集的列表,无论是否使用,或者是否已加载。基本上我需要Visual Studio中引用列表的副本列表。
有什么建议吗?
看看这些链接:
使用Reflection在C#中运行时加载未引用的程序集 [ ^ ]
http://stackoverflow.com/questions/463228/how-to-get-a-type-from-an-unreferenced-assembly [ ^ ]
http:/ /stackoverflow.com/questions/10719175/load - 在对象列表中的未引用组件类型 [ ^ ]
我希望此链接可以帮助您以其他方式解决您的问题:
http://adamthetech.com/2011/06/embed-dll-files-within-an-exe-c-sharp-winforms/ 一> [ ^ ]
I am still a bit of a noob.
I have a main app that loads plugins. I want to validate that all the Reference DLL's required to run the plugin exists in the Main App directory before I launch the plugin and if not, download it from a location.
Where I struggle is to get a list of references from the plugin.
I tried this:
List<assemblyname> a = Assembly.GetEntryAssembly().GetReferencedAssemblies().ToList();
But the problem is, this only gives me the assemblies loaded at that stage. I need a list of all the assemblies referenced in the app, whether used or not, or loaded or not. Basically I need a replica list of the References List in Visual Studio.
Any advice please?
Have a look at these links :
Using Reflection to load unreferenced assemblies at runtime in C#[^]
http://stackoverflow.com/questions/463228/how-to-get-a-type-from-an-unreferenced-assembly[^]
http://stackoverflow.com/questions/10719175/load-the-type-of-an-unreferenced-assembly-within-an-object-list[^]
I hope this link may help you to solve your problem in an alternative way :
http://adamthetech.com/2011/06/embed-dll-files-within-an-exe-c-sharp-winforms/[^]
这篇关于如何在C#中获取项目引用列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!