aws-sam-cli: API gate way still can't load assembly

Issue shown in command line

Command line showing Unhandled Exception: AWSLambda.Internal.Bootstrap.LambdaValidationException: Unable to load assembly ‘MCO.CancellationResolutionLambda.WebAPI’. at AWSLambda.Internal.Bootstrap.UserCodeLoader.Init(Action`1 customerLoggingAction) in /opt/workspace/LambdaSandboxCoreCLR-2-1/src/Bootstrap/UserCodeLoader.cs:line 115

File is there Name spaces are correct

Template file:

AWSTemplateFormatVersion: ‘2010-09-09’ Transform: AWS::Serverless-2016-10-31 Description: > sam-app

Sample SAM Template for sam-app

More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst

Globals: Function: Timeout: 180

Resources:

HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
        CodeUri: ../MCO.CancellationResolutionLambda.WebAPI/bin/Release/netcoreapp2.1/publish
        Handler: MCO.CancellationResolutionLambda.WebAPI::Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction::FunctionHandlerAsync
        Runtime: dotnetcore2.1
        Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
            Variables:
                ENVIRONMENT: dev
                SCENARIO: SA_RESOLVER_18_RETRY
                SNS_ERROR: mco_dev_errors
                TestFile: DefaultSamEnvSettings.xml
                LogicTest: true
        MemorySize: 256
        Events:
            HelloWorld:
                Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
                Properties:
                    Path: /mco-dev-soldnotcancelled-resolve-SA_RESOLVER_18_RETRY
                    Method: post

Outputs:

HelloWorldApi:
  Description: "API Gateway endpoint URL for Prod stage for Hello World function"
  Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"

HelloWorldFunction:
  Description: "Hello World Lambda Function ARN"
  Value: !GetAtt HelloWorldFunction.Arn

HelloWorldFunctionIamRole:
  Description: "Implicit IAM Role created for Hello World function"
  Value: !GetAtt HelloWorldFunctionRole.Arn

Command used sam local start-api

Does not work still. Needs fix

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

I have the same problem. Steps to reproduce: Created new web app in VS 2017 (aws Lambda Core Web Api template in file/new project) Executed “sam lambda package” (from AWS .NET global tools) Added template.yaml and updated .zip/assembly::lambdaEntryPoint locations Executed “sam local start-api --region us-east-1” in powershell Opened browsers, tried to hit that API endpoint, and I always get that “unable to load…” error. Btw, developing on Win10.

So how to even get simplest aspnet core hello-world with SAM running locally?

EDIT: I was able to find a workaround: downloaded .net core sdk for linux-x64 and copied all Microsoft.*.dll files into app deployment zip package (copying sdk from Win10 doesn’t work of course).