From 4a1c437f6024641b646c8e22050d83c016fa7edd Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sun, 9 Oct 2016 20:39:01 -0700 Subject: [PATCH] Don't fail precompiled view discovery if assembly is not managed --- .../Compilation/ViewsFeatureProvider.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/ViewsFeatureProvider.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/ViewsFeatureProvider.cs index 289d7da9f2..b55052589e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/ViewsFeatureProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/ViewsFeatureProvider.cs @@ -69,7 +69,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation if (File.Exists(precompiledAssemblyFilePath)) { - System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(precompiledAssemblyFilePath); + try + { + System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(precompiledAssemblyFilePath); + } + catch (FileLoadException) + { + // Don't throw if assembly cannot be loaded. This can happen if the file is not a managed assembly. + } } } #endif