FileLoadException: Could not load file or assembly 'Amazon.Lambda.RuntimeSupport, Version=1.8.0.0 #1186
-
Describe the bugI have updated my Lambda nuget packages. Amazon.Lambda.RuntimeSupport updated from 1.7 to 1.8. After deploying I am running into this error:
The lambdas are published through the Visual Studio AWS Toolkit extension on Windows 11. Expected BehaviorLambda runs and returns "ok". Current BehaviorLambda fails to execute with exception: Reproduction StepsI can reproduce with this project:
Program.cs
aws-lambda-tools-defaults.json
Possible SolutionNo response Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAmazon.Lambda.RuntimeSupport" Version="1.8.0" AWS Toolkit Version="1.28.0.0" Targeted .NET Platform.NET6 Operating System and versionWindows 11, dotnet6 |
Beta Was this translation helpful? Give feedback.
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: <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
Testing this function using "Hello World" input generates the below output: AWS Toolkit for Visual Studio 2022 version Thanks, |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
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