Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到方法-AWS.NET Core 3.1模拟Lambda测试工具_C#_Amazon Web Services_Aws Lambda_.net Core 3.1 - Fatal编程技术网

C# 找不到方法-AWS.NET Core 3.1模拟Lambda测试工具

C# 找不到方法-AWS.NET Core 3.1模拟Lambda测试工具,c#,amazon-web-services,aws-lambda,.net-core-3.1,C#,Amazon Web Services,Aws Lambda,.net Core 3.1,我正在尝试使用/设置AWS.NET Core 3.1模拟Lambda测试工具 目前,我将通过该工具启动应用程序,但是,一旦我尝试发送请求,就会收到错误“查找方法Init失败” 在aws lambda tools defaults.json中,我将函数处理程序设置为以下内容: “函数处理程序”:“Some.Example.Assembly::Some.Example.Namespace.LambdaProgram::Init” LambdaProgram.cs文件如下所示: 使用Amazon.L

我正在尝试使用/设置AWS.NET Core 3.1模拟Lambda测试工具

目前,我将通过该工具启动应用程序,但是,一旦我尝试发送请求,就会收到错误“查找方法Init失败”

aws lambda tools defaults.json中,我将
函数处理程序设置为以下内容:

“函数处理程序”:“Some.Example.Assembly::Some.Example.Namespace.LambdaProgram::Init”
LambdaProgram.cs文件如下所示:

使用Amazon.Lambda.AspNetCoreServer;
使用Microsoft.AspNetCore.Hosting;
名称空间Some.Example.namespace
{
公共类LambdaProgram:apigatewayhttpapiv2proxy函数
{
受保护的重写void Init(IWebHostBuilder)
{
builder.UseStartup();
}
}
}
除非我误读了文档,否则格式对我来说似乎是正确的

bin/
目录中,dll和exe具有匹配的名称,即“Some.Example.Assembly.exe”和“Some.Example.Assembly.dll”

如果我更改
函数处理程序
路径,那么我可以让它为类型抛出一个错误。但我不明白为什么它找不到函数Init?应用程序生成,并且
LambdaProgram
正在根据需要实现AWS接口


任何帮助都将是惊人的,我真的希望能够在部署之前在本地进行测试/调试(这是生产中的一个现有应用程序-这只是lamabda迁移的一个例子)

在完全困惑了几个小时之后,我找到了解决方案。这可能在文档中,我没有看到它,但是
函数处理程序
不是LambdaProgram类中的函数(或者您调用的任何函数)

相反,您应该使用
FunctionHandlerAsync
,我猜这是继承的

我通过克隆和查看他们的样本发现了这一点,其中有一条评论详细说明了这一点

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using System.IO;

namespace BlueprintBaseName._1
{
    /// <summary>
    /// This class extends from APIGatewayProxyFunction which contains the method FunctionHandlerAsync which is the 
    /// actual Lambda function entry point. The Lambda handler field should be set to
    /// 
    /// BlueprintBaseName.1::BlueprintBaseName.1.LambdaEntryPoint::FunctionHandlerAsync
    /// </summary>
    public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction

        protected override void Init(IWebHostBuilder builder)
        {
            builder
                .UseStartup<Startup>();
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
Net系统;
使用System.Threading.Tasks;
使用Microsoft.AspNetCore.Hosting;
使用System.IO;
命名空间BlueprintBaseName.\u 1
{
/// 
///此类扩展自APIGatewayProxyFunction,该函数包含方法FunctionHandlerAsync,该方法是
///实际Lambda函数入口点。Lambda处理程序字段应设置为
/// 
///BlueprintBaseName.1::BlueprintBaseName.1.LambdaEntryPoint::FunctionHandlerAsync
/// 
公共类lambdaintrypoint:Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
受保护的重写void Init(IWebHostBuilder)
{
建设者
.UseStartup();
}
}
}