Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/RouteJs.Mvc4/MvcRouteFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Web.Mvc;
using System.Web.Routing;
using System.Linq;
using System.Reflection;

namespace RouteJs.Mvc
{
Expand Down Expand Up @@ -61,7 +62,7 @@ private void BuildLists()
{
// Get all the controllers from all loaded assemblies
var controllers = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.SelectMany(GetTypesFromAssembly)
.Where(type => type.IsSubclassOf(typeof(Controller)))
.ToList();

Expand All @@ -81,6 +82,18 @@ private void BuildLists()
}
}
}

private IEnumerable<Type> GetTypesFromAssembly(Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException)
{
return new Type[] { };
}
}

/// <summary>
/// Gets a mapping of namespace prefix to area name
Expand Down