Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
C#
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
C#
AppDomain.CurrentDomain.GetAssemblies()
but i am only getting ConsoleApplication2 [startup project] classes.
Posted
Updated 30-Mar-16 21:01pm

1 solution

You have to load the assembly you are trying to use reflection on:
C#
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);

Assembly Class[^]
Assembly.LoadFile Method (String)[^]
 
Share this answer
 
Comments
_ProgProg_ 31-Mar-16 3:20am    
Thanks, It works fine after i loaded assembly.
phil.o 31-Mar-16 3:37am    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900