Fix webfx compile error.

- Assembly.Load(byte[]) has been removed
- Added IAssemblyLoaderEngine type that flows from the host
This commit is contained in:
David Fowler 2014-03-06 22:11:10 -08:00
parent 4d1768ce3c
commit eb61728107
2 changed files with 16 additions and 1 deletions

View File

@ -14,12 +14,15 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
{
private readonly IMetadataReferenceProvider _provider;
private readonly IApplicationEnvironment _environment;
private readonly IAssemblyLoaderEngine _loader;
public RoslynCompilationService(IServiceProvider serviceProvider)
{
// TODO: Get these services via ctor injection when we get container chaining implemented
_provider = (IMetadataReferenceProvider)serviceProvider.GetService(typeof(IMetadataReferenceProvider));
_environment = (IApplicationEnvironment)serviceProvider.GetService(typeof(IApplicationEnvironment));
_loader = (IAssemblyLoaderEngine)serviceProvider.GetService(typeof(IAssemblyLoaderEngine));
}
public Task<CompilationResult> Compile(string content)
@ -57,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
}
// TODO: Flow loader to this code so we're not using Load() directly
var type = Assembly.Load(ms.ToArray())
var type = _loader.LoadBytes(ms.ToArray(), null)
.GetExportedTypes()
.First();

View File

@ -0,0 +1,12 @@
using System.Reflection;
using Microsoft.Net.Runtime.Services;
namespace Microsoft.Net.Runtime
{
[AssemblyNeutral]
public interface IAssemblyLoaderEngine
{
Assembly LoadFile(string path);
Assembly LoadBytes(byte[] assemblyBytes, byte[] pdbBytes);
}
}