Swallow errors while trying to load types.

This commit is contained in:
David Fowler 2014-01-26 03:38:24 -08:00
parent 2ea440609c
commit ea97108e76
1 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.DependencyInjection; using Microsoft.AspNet.DependencyInjection;
@ -22,6 +24,8 @@ namespace Microsoft.AspNet.Mvc
} }
foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
{
try
{ {
var type = a.GetType(controllerName) ?? var type = a.GetType(controllerName) ??
a.GetType(a.GetName().Name + "." + controllerName); a.GetType(a.GetName().Name + "." + controllerName);
@ -34,6 +38,15 @@ namespace Microsoft.AspNet.Mvc
return ActivatorUtilities.CreateInstance(_serviceProvider, type); return ActivatorUtilities.CreateInstance(_serviceProvider, type);
} }
} }
catch (ReflectionTypeLoadException)
{
// TODO: Trace here
}
catch (Exception)
{
// TODO: Trace here
}
}
return null; return null;
} }