Aws-lambda-dotnet: Are Razor Pages supported?

Created on 30 Jan 2017  路  19Comments  路  Source: aws/aws-lambda-dotnet

Hi Norm,

Is it possible to invoke MVC routes like /home/about via Lambda? /api/values of course works fine but right now /home/about return an error 500. Is invoking the MVC razor path even possible through Lambda (since it will return HTML rather than JSON)?

Thanks,

Dave

guidance

Most helpful comment

@ebekker Agreed on the renaming

@slang25 I believe pre-compiled is only supported in .NET Core 1.1

Today Lambda pushed out a fix for loading dynamic Assemblies which was part of the problem. We have a couple more changes we need to get on the service side before Razor pages will work but we are making progress.

All 19 comments

I tried to return back Razor pages the other day and the Roslyn compiler was having trouble finding assemblies. Is that the same error you see in your CloudWatch Logs? Its something I want to get working but I haven't had time yet to do deeper research.

Is there a way to pull the whole stack trace in one go from CloudWatch? Or just line by line?

Line by line the stack trace is:

System.InvalidOperationException: Can not find compilation library location for package 'AWSMVC'
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
at System.Linq.Enumerable.d__1572.MoveNext() at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable1 parts, MetadataReferenceFeature feature)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeatureTFeature
at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.GetCompilationReferences()
at System.Threading.LazyInitializer.EnsureInitializedCoreT

So from the trace it looks like PopulateFeature cannot find or has the wrong path. Is there anything I can do to help? Please let me know.
BTW: https://github.com/aspnet/Tooling/issues/852 might have some similarities?

I would like to invoke razor views from API Gateway as well and am getting the same exception.

An unhandled exception has occurred: Can not find compilation library location for package 'ApiGateway'
System.InvalidOperationException: Can not find compilation library location for package 'ApiGateway'
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()

Is there any guidance on how to fix this or possibly a feature to support razor views?

Sorry not yet.

Hi Norm,

Did you get a change to look at the Razor issue? I know there is a lot going on, but this one is a watershed.
Will it be resolvable or is this a much bigger issue?

Thanks,
Dave

Hi Dave

We are still working on the issue. I'm hopeful it is resolvable but it is going to take some time.

Norm

Ok, ready to test it when you have it ready :-)

Suggest renaming the issue to something more descriptive like Are Razor Pages supported?

It might be worth testing it with pre-compiled razor views, take the burden away from the runtime.

@ebekker Agreed on the renaming

@slang25 I believe pre-compiled is only supported in .NET Core 1.1

Today Lambda pushed out a fix for loading dynamic Assemblies which was part of the problem. We have a couple more changes we need to get on the service side before Razor pages will work but we are making progress.

Hi,

While trying to get around the Lambda's dynamic assembly loading limitation by embedding the cshtml views into the library itself and then serving them from the embedded resource, I am hitting a roadblock when RazorViewEngine tries to compile the cshtml.

The error is a TypeInitializationException, thrown when initialising Microsoft.Extensions.DependencyModel.CompilationLibrary. It is thrown when RuntimeEnvironment is initialising it's static fields. The underlying cause seems to be that the Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment is throwing a System.PlatformNotSupportedException when trying to resolve the OS.

I have replicated the issue by Referencing any field or method in the Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment. This happens only when the code is running in Lambda, but not Locally or in Docker.

Does anyone know if there is a way to work-around this issue?

Cheers :)

@nosider, thanks for reporting this! Could you provide the stack trace for the case where Microsoft.Extensions.DependencyModel.CompilationLibrary throws TypeInitializationException?

Hope this helps :-)

Unknown error responding to request: TypeInitializationException: System.TypeInitializationException: The type initializer for 'Microsoft.Extensions.DependencyModel.CompilationLibrary' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Runtime.InteropServices.OSPlatform.get_Windows() at Microsoft.DotNet.PlatformAbstractions.Native.PlatformApis.DetermineOSPlatform() at System.Lazy'1.CreateValue() at System.Lazy'1.LazyInitValue() at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor() --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver..ctor() at Microsoft.Extensions.DependencyModel.CompilationLibrary..cctor() --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() at System.Linq.Enumerable.<SelectManyIterator>d__159'2.MoveNext() at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable'1 parts, MetadataReferenceFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.GetCompilationReferences() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func'1 valueFactory) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.get_CompilationReferences() at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.Compile(RelativeFileInfo fileInfo, String compilationContent) at Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.CreateCacheEntry(String relativePath, String normalizedPath, Func'2 compile) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.GetOrAdd(String relativePath, Func'2 compile) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet'1 expirationTokens, String relativePath, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult) at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResultAsync>d__32.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResultFilterAsync>d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAllResultFiltersAsync>d__29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResourceFilterAsync>d__23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.<ProcessRequest>d__15.MoveNext() TypeInitializationException: System.TypeInitializationException: The type initializer for 'Microsoft.Extensions.DependencyModel.CompilationLibrary' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Runtime.InteropServices.OSPlatform.get_Windows() at Microsoft.DotNet.PlatformAbstractions.Native.PlatformApis.DetermineOSPlatform() at System.Lazy'1.CreateValue() at System.Lazy'1.LazyInitValue() at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor() --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver..ctor() at Microsoft.Extensions.DependencyModel.CompilationLibrary..cctor() --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() at System.Linq.Enumerable.<SelectManyIterator>d__159'2.MoveNext() at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable'1 parts, MetadataReferenceFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.GetCompilationReferences() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func'1 valueFactory) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.get_CompilationReferences() at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService.Compile(RelativeFileInfo fileInfo, String compilationContent) at Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.CreateCacheEntry(String relativePath, String normalizedPath, Func'2 compile) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.GetOrAdd(String relativePath, Func'2 compile) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet'1 expirationTokens, String relativePath, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult) at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResultAsync>d__32.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResultFilterAsync>d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAllResultFiltersAsync>d__29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResourceFilterAsync>d__23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.<ProcessRequest>d__15.MoveNext() TypeInitializationException: System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Runtime.InteropServices.OSPlatform.get_Windows() at Microsoft.DotNet.PlatformAbstractions.Native.PlatformApis.DetermineOSPlatform() at System.Lazy'1.CreateValue() at System.Lazy'1.LazyInitValue() at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor() --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver..ctor() at Microsoft.Extensions.DependencyModel.CompilationLibrary..cctor() PlatformNotSupportedException: System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Runtime.InteropServices.OSPlatform.get_Windows() at Microsoft.DotNet.PlatformAbstractions.Native.PlatformApis.DetermineOSPlatform() at System.Lazy'1.CreateValue() at System.Lazy'1.LazyInitValue() at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor()

@nosider , which version of .NET Core are you using, could you share the project.json? I was able to access properties on RuntimeEnvironment without any issues. Here are the values I get.

RuntimeEnvironment.RuntimeArchitecture = x64
RuntimeEnvironment.OperatingSystem = amzn
RuntimeEnvironment.OperatingSystemPlatform = Linux
RuntimeEnvironment.OperatingSystemVersion = 2016.03

@gokarnm , Great! I guess it is a problem on my end and hence it can be resolved.

Just to be sure I have just tried again, by running at app locally and in Docker and it was successful. Then I published it to Lambda, where it still fails unfortunately.

Below are the project.json contents (the references are hierarchical)

Actual Lambda Project

{
    "version": "1.0.0-*",
    "buildOptions": {
        "emitEntryPoint": true,
        "preserveCompilationContext": true
    },

    "dependencies": {
        "Microsoft.NETCore.App": {
            "version": "1.0.0",
            "type": "platform"
        },
        "AWSSDK.Extensions.NETCore.Setup": "3.3.0.2",
        "AWSSDK.S3": "3.3.5.2",
        "Amazon.Lambda.Core": "1.0.0",
        "Amazon.Lambda.AspNetCoreServer": "0.9.0-preview1",
        "Amazon.Lambda.Logging.AspNetCore": "1.0.0",
        "Amazon.Lambda.Serialization.Json": "1.0.1",
        "Amazon.Lambda.Tools": {
            "type": "build",
            "version": "1.2.1-preview1"
        },
        "JE.AspNetCore.Example": "1.0.0-*"
    },

    "tools": {
        "Amazon.Lambda.Tools": "1.2.1-preview1",
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
    },

    "frameworks": {
        "netcoreapp1.0": {
            "imports": "dnxcore50"
        }
    },

    "publishOptions": {
        "include": [
            "wwwroot",
            "**/*.cshtml",
            "appsettings.json"
        ]
    },

    "scripts": {
        "postpublish": [
            "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
        ]
    }
}

which in-turn references JE.AspNetCore.Example

{
    "version": "1.0.0-*",

    "dependencies": {
        "JE.NetCore.Asp": "1.0.0-*"
    },

    "frameworks": {
        "netcoreapp1.0": {
            "imports": "dnxcore50"
        }
    },
    "buildOptions": {
        "embed": "Views/**/*.cshtml"
    }
}

which in-turn references JE.NetCore.Asp

{
  "version": "1.0.0-*",

    "dependencies": {
        "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
        "Microsoft.AspNetCore.Mvc": "1.0.1",
        "Microsoft.AspNetCore.Routing": "1.0.1",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
        "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
        "Microsoft.Extensions.Configuration.Json": "1.0.0",
        "Microsoft.Extensions.Logging": "1.0.0",
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
        "JE.NetCore": "1.0.0-*",
        "Newtonsoft.Json": "9.0.1",
        "Microsoft.AspNetCore.Diagnostics": "1.1.0",
        "Microsoft.Extensions.FileProviders.Embedded": "1.1.0"
    },

    "frameworks": {
        "netcoreapp1.0": {
            "imports": "dnxcore50"
        }
    }
}

which in turn references JE.NetCore

{
  "version": "1.0.0-*",

    "dependencies": {
        "Autofac": "4.3.0",
        "Autofac.Extensions.DependencyInjection": "4.0.0",
        "Microsoft.DotNet.InternalAbstractions": "1.0.0",
        "Microsoft.Extensions.DependencyInjection": "1.0.0",
        "Microsoft.Extensions.DependencyModel": "1.1.0",
        "Microsoft.Extensions.PlatformAbstractions": "1.0.0",
        "System.Runtime.Loader": "4.3.0"
    },

    "frameworks": {
        "netcoreapp1.0": {
            "imports": "dnxcore50"
        }
    }
}

Here are the Logs to show the sequence of events:

02:51:00 START RequestId: 8cb5e60c-0abc-11e7-8a1f-13c38df468a9 Version: $LATEST
02:51:02 Incoming GET requests to /
02:51:02 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting GET https://nj47fchh4i.execute-api.us-west-2.amazonaws.com/
02:51:03 [Debug] Microsoft.AspNetCore.Routing.Tree.TreeRouter: Request successfully matched the route with name '(null)' and template ''.
02:51:03 [Debug] Microsoft.AspNetCore.Mvc.Internal.ActionSelector: Action 'JE.AspNetCore.Example.Controllers.HomeController.WithQuestions (JE.AspNetCore.Example)' with id 'a07417df-ed55-4a84-acb9-6f6e2d50e3fe' did not match the constraint 'JE.NetCore.Asp.Constraints.QueryStringAttribute'
02:51:03 [Debug] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Executing action JE.AspNetCore.Example.Controllers.HomeController.Index (JE.AspNetCore.Example)
02:51:04 [Information] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Executing action method JE.AspNetCore.Example.Controllers.HomeController.Index (JE.AspNetCore.Example) with arguments ((null)) - ModelState is Valid
02:51:04 [Debug] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Executed action method JE.AspNetCore.Example.Controllers.HomeController.Index (JE.AspNetCore.Example), returned result Microsoft.AspNetCore.Mvc.ViewResult.
02:51:05 [Debug] Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine: View lookup cache miss for view 'Index' in controller 'Home'.
02:51:05 [Debug] Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService: Code generation for the Razor file at '/Views/Home/Index.cshtml' started.
02:51:08 [Debug] Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService: Code generation for the Razor file at '/Views/Home/Index.cshtml' completed in 2882.2923ms.
02:51:08 [Debug] Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRoslynCompilationService: Compilation of the generated code for the Razor file at '/Views/Home/Index.cshtml' started.
02:51:09 Unknown error responding to request: TypeInitializationException: System.TypeInitializationException: The type initializer for 'Microsoft.Extensions.DependencyModel.CompilationLibrary' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment' threw an exception. ---> System.PlatformNotSupportedException: Operati
02:51:09 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request finished in 7160.6994ms 0
02:51:09 END RequestId: 8cb5e60c-0abc-11e7-8a1f-13c38df468a9 

Found the issue that was causing the error. The error was caused by these two references:
"Microsoft.AspNetCore.Diagnostics": "1.1.0"
"Microsoft.Extensions.FileProviders.Embedded": "1.1.0"

Once I downgraded their version, the TypeInitializationException stopped happening.
"Microsoft.AspNetCore.Diagnostics": "1.0.2"
"Microsoft.Extensions.FileProviders.Embedded": "1.0.1"

Now that this part is working, the next hurdle is looking down on me - to see if it is possible to work around the reliance of MetadataReferenceFeatureProvider method PopulateFeature on the Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() method that does not work in Lambda.

Yes, this is hugely annoying from Microsoft. They keep wanting to load the 1.1 version of libraries. We should be able to set .NET Core 1.0 in Nuget and only see compatible items. After all Microsoft introduced the concept of LTS support only for 1.0.

Anyone have any insight as to if the .NET Core 2.0 will be an LTS version? I sure hope so.

I have given Microsoft feedback about this, but of course no response. Amazon rocks in that regard.

Closing this in favor of issue https://github.com/aws/aws-lambda-dotnet/issues/149 which covers .NET Core 2.0 which is where Razor pages will work.

Was this page helpful?
0 / 5 - 0 ratings