From bb5eb966254a46e090077837a9d48408e8dcbb77 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 25 May 2017 10:58:43 -0700 Subject: [PATCH] Load the precompilation type from the loaded assembly --- .../Compilation/CompiledViewManfiest.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/CompiledViewManfiest.cs b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/CompiledViewManfiest.cs index 089a9fab2e..b642d92b3e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/CompiledViewManfiest.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/Compilation/CompiledViewManfiest.cs @@ -15,19 +15,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation public static Type GetManifestType(AssemblyPart assemblyPart, string typeName) { - EnsureFeatureAssembly(assemblyPart); - - var precompiledAssemblyName = new AssemblyName(assemblyPart.Assembly.FullName); - precompiledAssemblyName.Name = precompiledAssemblyName.Name + PrecompiledViewsAssemblySuffix; - - return Type.GetType($"{typeName},{precompiledAssemblyName}"); + var assembly = GetFeatureAssembly(assemblyPart); + return assembly?.GetType(typeName); } - private static void EnsureFeatureAssembly(AssemblyPart assemblyPart) + private static Assembly GetFeatureAssembly(AssemblyPart assemblyPart) { if (assemblyPart.Assembly.IsDynamic || string.IsNullOrEmpty(assemblyPart.Assembly.Location)) { - return; + return null; } var precompiledAssemblyFileName = assemblyPart.Assembly.GetName().Name @@ -41,13 +37,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation { try { - Assembly.LoadFile(precompiledAssemblyFilePath); + return Assembly.LoadFile(precompiledAssemblyFilePath); } catch (FileLoadException) { // Don't throw if assembly cannot be loaded. This can happen if the file is not a managed assembly. } } + + return null; } } }