Unable to load assembly type (C # Amazon lambda function)

Since Amazon now supports C # for building AWMS Lambda functions, I wanted to try, but I was stuck when running the test.

This is my simple class:

using System; using System.IO; using System.Text; using Amazon.Lambda.Core; //using Amazon.Lambda.Serialization.Json; namespace MyTest { public static class LambdaFunction { public static string Handler(Stream stream) { return "Hello World"; } } } 

I compiled it using .Net Core. The result is a netstandard1.4 folder with the MyTest.dll build file and the MyTest.deps.json file. These compressed as .zip are downloaded to the AWS Lambda console.

On the configuration tab, the handler is defined as:

 MyTest::LambdaFunction::Handler 

But when I press the TEST button, this returns an error message:

 { "errorType": "LambdaException", "errorMessage": "Unable to load type 'LambdaFunction' from assembly 'MyTest, Culture=neutral, PublicKeyToken=null'." } 

Note1: before I found out that I needed to use .Net Core instead of the full CLR, I received an error message that the assembly could not be loaded, so I decided that the assembly was now compiled.

Note2: I tried several types of arguments (Stream and String are the only ones supported without a special serializer, though) for the Handler method, as well as the static / instance class or method or any combination, all to no avail.

Anyone who has already got this job and can give me some pointers?

+7
source share
2 answers

Well, this is one of those days that I think ....

Answer: I forgot to include the namespace 8 |

Must be:

 MyTest::MyTest.LambdaFunction::Handler 
+14
source

If today I had the same problem, I could fix it, here is the correct format that needs to be transferred:

 AssembleName::NameSpace.ClassName::FunctionHandlerName 
0
source

Source: https://habr.com/ru/post/1012907/


All Articles