I have a webforms 4.0 application that included MVC controller and view through scaffolding. Compiles fine.
On running I get issues AreaRegistration.RegisterAllAreas() in the global.asax.cs
Here is the stack trace....
Could not load file or assembly 'lala' or one of its dependencies. The specified module could not be found.
[FileNotFoundException: Could not load file or assembly 'BusinessObjects.Enterprise.Sdk.ZipLib.netmodule' or one of its dependencies. The specified module could not be found.]
System.Reflection.RuntimeAssembly.GetModules(RuntimeAssembly assembly, Boolean loadIfNotFound, Boolean getResourceModules, ObjectHandleOnStack retModuleHandles) +0
System.Reflection.RuntimeAssembly.GetModulesInternal(Boolean loadIfNotFound, Boolean getResourceModules) +34
System.Reflection.RuntimeAssembly.GetModules(Boolean getResourceModules) +16
System.Reflection.Assembly.GetTypes() +18
System.Web.Mvc.TypeCacheUtil.FilterTypesInAssemblies(IBuildManager buildManager, Predicate`1 predicate) +241
System.Web.Mvc.TypeCacheUtil.GetFilteredTypesFromAssemblies(String cacheName, Predicate`1 predicate, IBuildManager buildManager) +131
System.Web.Mvc.ControllerTypeCache.EnsureInitialized(IBuildManager buildManager) +164
System.Web.Mvc.DefaultControllerFactory.GetControllerTypeWithinNamespaces(RouteBase route, String controllerName, HashSet`1 namespaces) +91
.................
I can comment out AreaRegistration.RegisterAllAreas( and it will do the same once hitting the route.
I believe the DefaultControllerFactory is using reflection to go through my project, not finding my controller and then searching every referenced assembly which for some reason is confusing it. It's not easy to just start removing assemblies from the project.
I've tried to limit it's searching from suggestion from this link.
Controller lookup and default controller factory[
^]
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "BI.UI.WebApp.Controllers" }
);
}
}
Also adding this to the global.asax
ControllerBuilder.Current.DefaultNamespaces.Clear();
ControllerBuilder.Current.DefaultNamespaces.Add("BI.UI.WebApp.Controllers");
........
I verified the controller is in that namespace
namespace BI.UI.WebApp.Controllers
{
public class DefaultController : Controller
{
......
What else can anyone suggest to do?