-
Notifications
You must be signed in to change notification settings - Fork 494
FileLoadException: Could not load file or assembly 'Amazon.Lambda.RuntimeSupport, Version=1.8.0.0 #1186
-
Describe the bug
I have updated my Lambda nuget packages. Amazon.Lambda.RuntimeSupport updated from 1.7 to 1.8. After deploying I am running into this error:
START RequestId: f3fdad76-e4ac-45d9-81aa-4f04977b31a Version: $LATEST
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Amazon.Lambda.RuntimeSupport, Version=1.8.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Amazon.Lambda.RuntimeSupport, Version=1.8.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'
at Program.<Main>$(String[] args)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Program.<Main>$(String[] args)
at Program.<Main>(String[] args)
END RequestId: f3fdad76-e4ac-45d9-81aa-4f04977b31a
REPORT RequestId: f3fdad76-e4ac-45d9-81aa-4f04977b31a Duration: 1024.21 ms Billed Duration: 1025 ms Memory Size: 128 MB Max Memory Used: 15 MB
RequestId: f3fdad76-e4ac-45d9-81aa-4f04977b31a Error: Runtime exited with error: signal: aborted
Runtime.ExitError
The lambdas are published through the Visual Studio AWS Toolkit extension on Windows 11.
Expected Behavior
Lambda runs and returns "ok".
Current Behavior
Lambda fails to execute with exception:
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Amazon.Lambda.RuntimeSupport, Version=1.8.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Amazon.Lambda.RuntimeSupport, Version=1.8.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'
Reproduction Steps
I can reproduce with this project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Generate ready to run images during publishing to improve cold start time. -->
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.0" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />
</ItemGroup>
</Project>
Program.cs
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;
using var handlerWrapper = HandlerWrapper.GetHandlerWrapper(() => "ok", new CamelCaseLambdaJsonSerializer());
using var bootstrap = new LambdaBootstrap(handlerWrapper);
await bootstrap.RunAsync();
aws-lambda-tools-defaults.json
{
"Information" : [
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
"To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
"dotnet lambda help",
"All the command line options for the Lambda command can be specified in this file."
],
"profile" : "default",
"region" : "eu-west-1",
"configuration" : "Release",
"framework" : "net6.0",
"function-runtime" : "dotnet6",
"function-memory-size" : 128,
"function-timeout" : 10,
"function-handler" : "TestLambda",
"function-name" : "TestLambda",
"function-description" : "",
"package-type" : "Zip",
"function-role" : "arn:aws:iam::19xx:role/xxx",
"tracing-mode" : "PassThrough",
"environment-variables" : "",
"image-tag" : "",
"function-architecture" : "x86_64"
}
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Amazon.Lambda.RuntimeSupport" Version="1.8.0"
Amazon.Lambda.Core" Version="2.1.0"
Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0"
AWS Toolkit Version="1.28.0.0"
Targeted .NET Platform
.NET6
Operating System and version
Windows 11, dotnet6
Beta Was this translation helpful? Give feedback.
All reactions
Hi @denxorz,
Good morning.
Somehow I'm unable to reproduce the issue. I developed new .NET 6 custom runtime function using AWS Visual Studio 2022 lambda template. Below are the source files generated:
.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <AWSProjectType>Lambda</AWSProjectType> <AssemblyName>bootstrap</AssemblyName> <!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. --> <CopyLocalLockFileAssemblies>true</C...
Replies: 3 comments 1 reply
-
Hi @denxorz,
Good morning.
Somehow I'm unable to reproduce the issue. I developed new .NET 6 custom runtime function using AWS Visual Studio 2022 lambda template. Below are the source files generated:
.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <AWSProjectType>Lambda</AWSProjectType> <AssemblyName>bootstrap</AssemblyName> <!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. --> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- Enable trimming to reduce package size of self contained publish which can reduce cold starts. Trimming alters the .NET assemblies put in the deployment package. Additional runtime testing is required to make sure trimming does not have any unattended consequences. <PublishTrimmed>true</PublishTrimmed> --> <!-- Generate ready to run images during publishing to improve cold start time. --> <PublishReadyToRun>true</PublishReadyToRun> </PropertyGroup> <!-- When publishing Lambda functions for ARM64 to the provided.al2 runtime a newer version of libicu needs to be included in the deployment bundle because .NET requires a newer version of libicu then is preinstalled with Amazon Linux 2. --> <ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'"> <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" /> <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" /> </ItemGroup> <ItemGroup> <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.0" /> <PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" /> </ItemGroup> </Project>
Function.cs
using Amazon.Lambda.Core; using Amazon.Lambda.RuntimeSupport; using Amazon.Lambda.Serialization.SystemTextJson; namespace AWSLambdaCustomRuntimeNet6; public class Function { /// <summary> /// The main entry point for the custom runtime. /// </summary> /// <param name="args"></param> private static async Task Main(string[] args) { Func<string, ILambdaContext, string> handler = FunctionHandler; await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer()) .Build() .RunAsync(); } /// <summary> /// A simple function that takes a string and does a ToUpper /// /// To use this handler to respond to an AWS event, reference the appropriate package from /// https://github.com/aws/aws-lambda-dotnet#events /// and change the string input parameter to the desired event type. /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public static string FunctionHandler(string input, ILambdaContext context) { return input.ToUpper(); } }
aws-lambda-tools.defaults.json
{
"Information" : [
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
"To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
"dotnet lambda help",
"All the command line options for the Lambda command can be specified in this file."
],
"profile" : "default",
"region" : "us-east-2",
"configuration" : "Release",
"function-runtime" : "provided.al2",
"function-memory-size" : 256,
"function-timeout" : 30,
"function-handler" : "bootstrap",
"msbuild-parameters" : "--self-contained true",
"framework" : "net6.0",
"function-name" : "TestCustomRuntimeFunction",
"package-type" : "Zip",
"function-role" : "arn:aws:iam::<<account-id>>:role/lambda_exec_TestCustomRuntimeFunction",
"function-architecture" : "x86_64",
"tracing-mode" : "PassThrough",
"environment-variables" : "",
"image-tag" : ""
}When I deploy the function using Visual Studio 2022 Publish to AWS Lambda, here's the build output generated:
Created IAM Role lambda_exec_TestCustomRuntimeFunction
Attached policy AWSLambdaExecute to role lambda_exec_TestCustomRuntimeFunction
Created IAM role arn:aws:iam::<<account-id>>:role/lambda_exec_TestCustomRuntimeFunction with managed policy AWSLambdaExecute
Waiting for new IAM Role to propagate to AWS regions
Executing publish command
... invoking 'dotnet publish', working folder '<<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\publish'
... dotnet publish --output "<<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\publish" --configuration "Release" --framework "net6.0" --self-contained true /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64
... publish: Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
... publish: Copyright (C) Microsoft Corporation. All rights reserved.
... publish: Determining projects to restore...
... publish: Restored <<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6.csproj (in 431 ms).
... publish: AWSLambdaCustomRuntimeNet6 -> <<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\linux-x64\bootstrap.dll
... publish: AWSLambdaCustomRuntimeNet6 -> <<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\publish\
Zipping publish folder <<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\publish to <<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\AWSLambdaCustomRuntimeNet6.zip
... zipping: Amazon.Lambda.Core.dll
... zipping: Amazon.Lambda.RuntimeSupport.dll
... zipping: Amazon.Lambda.Serialization.SystemTextJson.dll
... zipping: bootstrap
... zipping: bootstrap.deps.json
... zipping: bootstrap.dll
... zipping: bootstrap.pdb
... zipping: bootstrap.runtimeconfig.json
... zipping: createdump
... zipping: libclrjit.so
... zipping: libcoreclr.so
... zipping: libcoreclrtraceptprovider.so
... zipping: libdbgshim.so
... zipping: libhostfxr.so
... zipping: libhostpolicy.so
... zipping: libmscordaccore.so
... zipping: libmscordbi.so
...
...
...
... zipping: System.Xml.Serialization.dll
... zipping: System.Xml.XDocument.dll
... zipping: System.Xml.XmlDocument.dll
... zipping: System.Xml.XmlSerializer.dll
... zipping: System.Xml.XPath.dll
... zipping: System.Xml.XPath.XDocument.dll
... zipping: WindowsBase.dll
Created publish archive (<<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\bin\Release\net6.0\AWSLambdaCustomRuntimeNet6.zip).
Creating new Lambda function TestCustomRuntimeFunction
New Lambda function created
Config settings saved to <<Path-to-project>>\AWSLambdaCustomRuntimeNet6\AWSLambdaCustomRuntimeNet6\aws-lambda-tools-defaults.json
Testing this function using "Hello World" input generates the below output:
Screen Shot 2022年05月19日 at 10 46 36 AM
AWS Toolkit for Visual Studio 2022 version 1.29.0.0 used.
Thanks,
Ashish
Beta Was this translation helpful? Give feedback.
All reactions
-
I redeployed, with version 1.8 on runtime "dotnet6" and the problem no longer occurs on any of the Lambdas that had this issue before.
So I can no longer reproduce it. The issue can be closed, if you agree.
Beta Was this translation helpful? Give feedback.
All reactions
-
I had the issue again on two Lambdas. Upgrading the package to 1.8.1 fixed the issue.
Beta Was this translation helpful? Give feedback.
All reactions
-
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Beta Was this translation helpful? Give feedback.