Skip to content
Permalink
Browse files

fix: exception happening on startup of applications (#2253)

* fix: exception happening on startup of applications

* Change to using the current execution directory
  • Loading branch information
glennawatson committed Nov 20, 2019
1 parent 02e932d commit 11e7f70da146d0eda8d9d548af18b265d0516611
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/ReactiveUI/Mixins/DependencyResolverMixins.cs
@@ -6,6 +6,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@@ -44,7 +45,9 @@ public static void InitializeReactiveUI(this IMutableDependencyResolver resolver

var assemblyName = new AssemblyName(fdr.AssemblyQualifiedName.Replace(fdr.FullName + ", ", string.Empty));

extraNs.ForEach(ns => ProcessRegistrationForNamespace(ns, assemblyName, resolver));
extraNs
.Where(GetNamespaceExists)
.ForEach(ns => ProcessRegistrationForNamespace(ns, assemblyName, resolver));
}

/// <summary>
@@ -118,5 +121,12 @@ private static void ProcessRegistrationForNamespace(string ns, AssemblyName asse
registerer.Register((f, t) => resolver.RegisterConstant(f(), t));
}
}

private static bool GetNamespaceExists(string namespaceName)
{
string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string assemblyPath = Path.Combine(folderPath, new AssemblyName(namespaceName).Name + ".dll");
return File.Exists(assemblyPath);
}
}
}

0 comments on commit 11e7f70

Please sign in to comment.
You can’t perform that action at this time.