Swallow errors while trying to load types.
This commit is contained in:
parent
2ea440609c
commit
ea97108e76
|
|
@ -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;
|
||||||
|
|
||||||
|
|
@ -23,15 +25,26 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
var type = a.GetType(controllerName) ??
|
try
|
||||||
a.GetType(a.GetName().Name + "." + controllerName);
|
{
|
||||||
|
var type = a.GetType(controllerName) ??
|
||||||
|
a.GetType(a.GetName().Name + "." + controllerName);
|
||||||
#if NET45
|
#if NET45
|
||||||
type = type ?? a.GetTypes().FirstOrDefault(t => t.Name.Equals(controllerName, StringComparison.OrdinalIgnoreCase));
|
type = type ?? a.GetTypes().FirstOrDefault(t => t.Name.Equals(controllerName, StringComparison.OrdinalIgnoreCase));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (type != null)
|
if (type != null)
|
||||||
|
{
|
||||||
|
return ActivatorUtilities.CreateInstance(_serviceProvider, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ReflectionTypeLoadException)
|
||||||
{
|
{
|
||||||
return ActivatorUtilities.CreateInstance(_serviceProvider, type);
|
// TODO: Trace here
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// TODO: Trace here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue