如何获得解决方案中的所有装配 [英] How do I get all assemblies in the solution
问题描述
亲爱的,
我试图让所有课程都在一个有两个项目的解决方案中,但他们之间没有参考,但我只是在当前的初创公司上课项目。
这是我的情况:
*我在一个解决方案中有2个项目(ConsoleApplication2) - ConsoleApplication11)。
* ConsoleApplication2是启动项目。
*我尝试使用
AppDomain.CurrentDomain.GetAssemblies()
但我只获得了ConsoleApplication2 [启动项目] 类。
那么,如何在不添加引用的情况下获取ConsoleApplication11类它在ConsoleApplication2中。
等待你的快速行动,
问候,
Amr
我尝试了什么:
我试过用< pre lang =c#> AppDomain.CurrentDomain.GetAssemblies()
但我只得到ConsoleApplication2 [启动项目] c lasses。
你必须加载你试图使用反射的程序集:
< span class =code-keyword> string path = @ .. \..\ ConsoleApplication11\bin\Debug\ConsoleApplication11.exe跨度>; // 将正确的路径放到您要在此处加载的程序集
程序集consoleApp11 = Assembly.LoadFile(path);
汇编类 [ ^ ]
Assembly.LoadFile方法(字符串) [ ^ ]
Dears,
I am trying to get all classes in a solution that has two projects with no reference between them but i am only getting classes to the current startup project.
Here is my case:
* I have a 2 projects in one solution (ConsoleApplication2 - ConsoleApplication11).
* ConsoleApplication2 is the startup project.
* I tried using
AppDomain.CurrentDomain.GetAssemblies()
but i am only getting ConsoleApplication2 [startup project] classes.
So, How can i get ConsoleApplication11 classes without adding reference to it in ConsoleApplication2.
Waiting your fast actions,
Regards,
Amr
What I have tried:
I tried using
AppDomain.CurrentDomain.GetAssemblies()
but i am only getting ConsoleApplication2 [startup project] classes.
You have to load the assembly you are trying to use reflection on:
string path = @"..\..\ConsoleApplication11\bin\Debug\ConsoleApplication11.exe"; // Put the right path to the assembly you are trying to load here Assembly consoleApp11 = Assembly.LoadFile(path);
这篇关于如何获得解决方案中的所有装配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!