diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index fe0abcae02..4c2d5d599f 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -159,7 +159,7 @@ namespace MediaBrowser.Common.Implementations
protected IZipClient ZipClient { get; set; }
protected IIsoManager IsoManager { get; set; }
-
+
///
/// Initializes a new instance of the class.
///
@@ -243,7 +243,7 @@ namespace MediaBrowser.Common.Implementations
/// Runs the startup tasks.
///
/// Task.
- public virtual Task RunStartupTasks()
+ public virtual Task RunStartupTasks()
{
return Task.Run(() =>
{
@@ -384,7 +384,7 @@ namespace MediaBrowser.Common.Implementations
///
/// The type.
/// System.Object.
- public object CreateInstance(Type type)
+ protected object CreateInstance(Type type)
{
try
{
@@ -398,6 +398,25 @@ namespace MediaBrowser.Common.Implementations
}
}
+ ///
+ /// Creates the instance safe.
+ ///
+ /// The type.
+ /// System.Object.
+ protected object CreateInstanceSafe(Type type)
+ {
+ try
+ {
+ return Container.GetInstance(type);
+ }
+ catch (Exception ex)
+ {
+ Logger.Error("Error creating {0}", ex, type.Name);
+
+ return null;
+ }
+ }
+
///
/// Registers the specified obj.
///
@@ -496,7 +515,11 @@ namespace MediaBrowser.Common.Implementations
/// IEnumerable{``0}.
public IEnumerable GetExports(bool manageLiftime = true)
{
- var parts = GetExportTypes().Select(CreateInstance).Cast().ToList();
+ var parts = GetExportTypes()
+ .Select(CreateInstanceSafe)
+ .Where(i => i != null)
+ .Cast()
+ .ToList();
if (manageLiftime)
{
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 7cb58f580b..c634871fab 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -89,13 +89,6 @@ namespace MediaBrowser.Common
/// Task.
Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress progress);
- ///
- /// Creates an instance of type and resolves all constructor dependancies
- ///
- /// The type.
- /// System.Object.
- object CreateInstance(Type type);
-
///
/// Resolves this instance.
///