aws/aws-lambda-dotnet

[Amazon.Lambda.Logging.AspNetCore] System.MissingMethodException

Closed this issue · 4 comments

Describe the bug

Hello everyone!

I faced with the compatibility issue connected with the release of Amazon.Lambda.Logging.AspNetCore - 4.0.0.

I saw the list of changes in this PR: #2062

And one of the changes in this method:
https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.Logging.AspNetCore/LambdaILogger.cs#L87

And I see the dependency is also updated in Amazon.Lambda.Core - 2.6.0.

So, I have the following csproj for my lambda function:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <AWSProjectType>Lambda</AWSProjectType>
    <RootNamespace>func</RootNamespace>
    <AssemblyName>func</AssemblyName>
    <ImplicitUsings>enable</ImplicitUsings>
    <!-- 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 improvement cold starts. -->
    <PublishReadyToRun>true</PublishReadyToRun>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Amazon.Lambda.Core" Version="2.6.0" />
    <PackageReference Include="Amazon.Lambda.KinesisEvents" Version="3.0.0" />
    <PackageReference Include="Amazon.Lambda.Logging.AspNetCore" Version="4.0.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
    <PackageReference Include="AWSSDK.DynamoDBv2" Version="4.0.2.2" />
    <PackageReference Include="AWSSDK.SimpleNotificationService" Version="4.0.0.13" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
  </ItemGroup>
  <ItemGroup>
    <None Update="appsettings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>

For local testing I'm using AWS .NET 8.0 Mock Lambda Test Tool (0.16.2).

The build artifact was validated, and assemblies for both Amazon.Lambda.Logging.AspNetCore and Amazon.Lambda.Core have latest versions, and have mentioned changes.

But once I'm trying to run Lambda locally, I receive the following error:

System.MissingMethodException: Method not found: 'Void Amazon.Lambda.Core.LambdaLogger.Log(Amazon.Lambda.Core.LogLevel, System.String, System.Object[])'.
at Microsoft.Extensions.Logging.LambdaILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter) at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter)

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

My AWS Lambda works fine locally including logging with Amazon.Lambda.Logging.AspNetCore 4.0.0.

Current Behavior

Once I'm trying to run Lambda locally, I receive the following error:

System.MissingMethodException: Method not found: 'Void Amazon.Lambda.Core.LambdaLogger.Log(Amazon.Lambda.Core.LogLevel, System.String, System.Object[])'.
at Microsoft.Extensions.Logging.LambdaILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter) at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter)

Reproduction Steps

  1. Create a lambda with csproj in description.
  2. Run Lambda locally.

Possible Solution

No response

Additional Information/Context

Once I install Amazon.Lambda.Logging.AspNetCore 3.1.1, everything works fine. I have no chance to upload build to AWS, but tried both Debud/Release build modes.

AWS .NET SDK and/or Package version used

Amazon.Lambda.Logging.AspNetCore - 4.0.0.
Amazon.Lambda.Core - 2.6.0

Targeted .NET Platform

.NET 8

Operating System and version

Windows 11 (local runtime)

I'm working on getting the version of Amazon.Lambda.Core that the test tool is bringing to the latest.

Version 0.16.3 of the tool is out that now uses the latest version of Amazon.Lambda.Core. If you are using Visual Studio to use the tool it should auto update to the latest version when you restart Visual Studio and open a Lambda project.

Appreciate your help - issue has been gone!

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.