I have 2 projects in my solution. My first project is trying to search for all classes that are in a specific namespace and implement a specific interface.
My website runs of the first project and imports the second as a compiled dll. Now if I were to try and search for assemblies in a namespace that resides in my first project, then I have no issues, however the moment that I point to my second project, it can never find anything. Here is my code:
const string @namespace = "MySecondProject.Models";
var reports = from t in Assembly.GetExecutingAssembly().GetTypes()
where t.IsClass && t.Namespace == @namespace && typeof(IMyInterface).IsAssignableFrom(t)
select t;
I have also tried setting up the namespace variable to include second project name as i know this can be an issue when creating an instance of an object via reflection (encountered that before)
const string @namespace = "MySecondProject.Models,MySecondProject";
I am trying to understand why I am getting back no results and what is the correct way of doing this?
I have also tried removing my interface check, but I still get same results.
Aucun commentaire:
Enregistrer un commentaire