I want to list all the controllers of my Web Api project in another project (not in the same solution and a console app) using Reflection but I am getting error "Could not load file or assembly 'System.Web.Mvc, Version=5.2.0.0 ...".
Api project runs and work all fine. but when i load its dll using following code i get the exception
"An unhandled exception of type 'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll
Additional information: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
And then the LoaderExceptions property says;
{"Could not load file or assembly 'System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
Code:
var assembly = Assembly.LoadFile(_ApiUriPath);
var allControllers = from t in assembly.GetTypes()
where t.IsAbstract == false
where t.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)
select t;
i can confirm that the file System.Web.Mvc.dll is in the same folder (bin) where my api dll is.
help please.
Aucun commentaire:
Enregistrer un commentaire