aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.57k stars 479 forks source link

System.TypeLoadException: Method 'get_Features' #652

Closed rhysstubbs closed 3 years ago

rhysstubbs commented 4 years ago

Using the AWS Mock Lambda Test Tool to send a test request I receive the following exception:

System.TypeLoadException: Method 'get_Features' in type 'Amazon.Lambda.AspNetCoreServer.Internal.LambdaServer' from assembly 'Amazon.Lambda.AspNetCoreServer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604' does not have an implementation.
   at Amazon.Lambda.AspNetCoreServer.AbstractAspNetCoreFunction`2.Start()
   at Amazon.Lambda.AspNetCoreServer.AbstractAspNetCoreFunction`2..ctor(StartupMode startupMode)
   at Amazon.Lambda.AspNetCoreServer.AbstractAspNetCoreFunction`2..ctor()
   at Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction..ctor()
   at Some.Example.Namespace.LambdaProgram..ctor()

My configuration is very minimal, essentially a customised version of the boilerplate provided. I'm integrating with an existing .NET Core 3.1 Web API application. I'm assuming this isnt't coming rom the LambdaServer itself considering no .NET library use a convention seen in "get_Features"?

UPDATE

I cloned this repository and tested one of the .NET 3.1 blueprints, with complete success. I then took the startup, lambda entrypoint classes and example controller and tested my application again. Still no joy. I'm thinking this may be related to a particular dependency I have?

normj commented 4 years ago

Can you share your project file?

rhysstubbs commented 4 years ago

@normj Thanks for the reply.

Here is a copy of the .csproj file.

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AWSProjectType>Lambda</AWSProjectType>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <UserSecretsId>5faaa9bc-6caa-4911-ab02-8e8ed8990d80</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <StartupObject>Some.Example.Namespace.Program</StartupObject>
    <Platforms>AnyCPU;x64</Platforms>
  </PropertyGroup>

  <PropertyGroup>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
    <AssemblyName>Some.Example.Namespace</AssemblyName>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <NoWarn>1701;1702;2007</NoWarn>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <NoWarn>1701;1702;2007</NoWarn>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <NoWarn>1701;1702;1305;2007;</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="deployment\**" />
    <Content Remove="deployment\**" />
    <EmbeddedResource Remove="deployment\**" />
    <None Remove="deployment\**" />
  </ItemGroup>

  <ItemGroup>
    <Content Remove="appsettings.Development.json" Condition="Exists('appsettings.Development.json')" />
    <Content Remove="appsettings.Staging.json" Condition="Exists('appsettings.Development.json')" />
    <Content Remove="appsettings.Production.json" Condition="Exists('appsettings.Development.json')" />
    <Content Remove="appsettings.json" Condition="Exists('appsettings.json')" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="appsettings.Development.json" Condition="Exists('appsettings.Development.json')">
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </EmbeddedResource>
    <EmbeddedResource Include="appsettings.Staging.json" Condition="Exists('appsettings.Staging.json')">
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </EmbeddedResource>
    <EmbeddedResource Include="appsettings.Production.json" Condition="Exists('appsettings.Production.json')">
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </EmbeddedResource>
    <EmbeddedResource Include="appsettings.json" Condition="Exists('appsettings.json')">
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </EmbeddedResource>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="5.0.0" />
    <PackageReference Include="App.Metrics.Health.Abstractions" Version="3.2.0" />
    <PackageReference Include="AspNetCore.HealthChecks.Npgsql" Version="3.1.1" />
    <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.1" />
    <PackageReference Include="AWS.Logger.AspNetCore" Version="2.2.0" />
    <PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.3.101" />
    <PackageReference Include="Dapper" Version="2.0.35" />
    <PackageReference Include="Dommel" Version="1.11.0" />
    <PackageReference Include="HtmlAgilityPack" Version="1.11.23" />
    <PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.3" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.1.3" />
    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.3" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
    <PackageReference Include="Sentry.AspNetCore" Version="2.1.1" />
    <PackageReference Include="Sentry.Extensions.Logging" Version="2.1.1" />
    <PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0007" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.3.3" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.3.3" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.3.3" />
    <PackageReference Include="System.Collections" Version="4.3.0" />
    <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
    <PackageReference Include="WebMarkupMin.Core" Version="2.8.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Some.Example.Namespace.DataAccessFramework\Some.Example.Namespace.DataAccessFramework.csproj" />
    <ProjectReference Include="..\Some.Example.Namespace.DataAccess\Some.Example.Namespace.DataAccess.csproj" />
    <ProjectReference Include="..\Some.Example.Namespace.ImageUploadService\Some.Example.Namespace.Storage.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="wwwroot\articles\" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <Content Update="aws-lambda-tools-defaults.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

</Project>
ashishdhingra commented 4 years ago

Hi @rhysstubbs,

Good morning.

Please let me know if this is still an issue. If yes, request you to provide sample project code (with all sensitive information removed) to troubleshoot further.

Thanks, Ashish

github-actions[bot] commented 4 years ago

This issue has not recieved a response in 2 weeks. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.