It seems like I'm having an issue that I can't see others coming across. I've checked everything I can think of but no matter what I do, when the lambda test tool opens in the browser, it fails to load the functions list.
In the network tab I can see:
500 Error: http://localhost:5050/webtester-api/Tester/aws-lambda-tools-defaults.json
FileNotFoundException: Could not load file or assembly 'Amazon.Lambda.Serialization.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The system cannot find the file specified.
Full Stack Trace:
System.IO.FileNotFoundException: Could not load file or assembly 'Amazon.Lambda.Serialization.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The system cannot find the file specified.
File name: 'Amazon.Lambda.Serialization.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunction(LambdaFunctionInfo functionInfo) in C:\codebuild\tmp\output\src248644039\src\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 125
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunctions(IList`1 configInfos) in C:\codebuild\tmp\output\src248644039\src\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 69
at Amazon.Lambda.TestTool.WebTester.Controllers.TesterController.GetFunctions(String configFile) in C:\codebuild\tmp\output\src248644039\src\Tools\LambdaTestTool\Amazon.Lambda.TestTool\WebTester\Controllers\TesterController.cs:line 34
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Amazon.Lambda.TestTool.WebTester.Startup.<Configure>b__6_0(HttpContext context, Func`1 next) in C:\codebuild\tmp\output\src248644039\src\Tools\LambdaTestTool\Amazon.Lambda.TestTool\WebTester\Startup.cs:line 97
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Has anyone come across this before or can point me in the right direction? There are no errors in the console from me running it and I'm not totally sure where it's going wrong.
Might be worth mentioning that I'm running this on Ubuntu.
I'm working on a new version of this tool that is tied with the upcoming .NET Core 3.1 release but also still support .NET Core 2.1. I have been doing some rework to how the Lambda code is loaded. If I provided a link to a preview build would you be willing to try it out.
@normj definitely if it's backwards compatible with 2.1 since I would ideally not want to rework all my functions just yet 馃槄
Yeap, going forward there were be 2 separate tools one for 2.1 and one for 3.1 but they will share a lot of the same logic. Let me clean things up and then I'll add a link to the 2.1 version.
Appreciated thank you
Here is a link to a preview build of the upcoming version.
https://normj-packages.s3.us-west-2.amazonaws.com/Amazon.Lambda.TestTool-2.1.0.10.0-preview1.nupkg
To install it download the nupkg file. Then in the directory that you download the file to run the following command to update your existing version.
dotnet tool update -g amazon.lambda.testtool-2.1 --version 0.10.0-preview1 --add-source .
We were having trouble with 0.9.5 not loading the netstandard20 version of the NuGet package Microsoft.AspNet.WebApi.Client
. Updating to the 0.10.0 preview resolved our issue.
@brandon-king-halo Thanks for letting me know that 0.10.0 preview fixes the issue!
Apologies I've not had chance to test this yet. I should be able to look at it this week!
FYI If anyone has trouble installing the nupkg
locally. Run:
dotnet tool uninstall -g amazon.lambda.testtool-2.1
And then run:
dotnet tool install -g amazon.lambda.testtool-2.1 --version 0.10.0-preview1 --add-source .
@normj
I still get the same exception with the preview release:
System.IO.FileNotFoundException: Could not load file or assembly 'Amazon.Lambda.Serialization.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The system cannot find the file specified.
File name: 'Amazon.Lambda.Serialization.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604' ---> System.IO.FileNotFoundException: Could not load the specified file.
File name: 'Amazon.Lambda.Serialization.Json'
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunction(LambdaFunctionInfo functionInfo) in C:\codebase\aws-lambda-dotnet\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 135
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunctions(IList`1 configInfos) in C:\codebase\aws-lambda-dotnet\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 79
at Amazon.Lambda.TestTool.WebTester.Controllers.TesterController.GetFunctions(String configFile) in C:\codebase\aws-lambda-dotnet\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool.WebTester21\Controllers\TesterController.cs:line 29
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Amazon.Lambda.TestTool.WebTester.Startup.<Configure>b__6_0(HttpContext context, Func`1 next) in C:\codebase\aws-lambda-dotnet\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool.WebTester21\Startup.cs:line 95
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
You mentioned you were doing this on Ubuntu. Have you tried the same solution on anything besides Ubuntu? Wondering if this is a platform specific issue.
Might be related, tried to run using 3.1 and respective Test Tool on ubuntu 19.10.
dotnet new lambda.EmptyFunction --name LinuxFunction
dotnet restore
dotnet build
dotnet lambda-test-tool-3.1 --no-ui
dump:
AWS .NET Core 3.1 Mock Lambda Test Tool (0.10.0)
Loaded local Lambda runtime from project output /home/k/Documents/tmp/LinuxFunction/src/LinuxFunction/bin/Debug/netcoreapp3.1
Executing Lambda function without web interface
Found Lambda config file /home/k/Documents/tmp/LinuxFunction/src/LinuxFunction/aws-lambda-tools-defaults.json
... Using config file /home/k/Documents/tmp/LinuxFunction/src/LinuxFunction/aws-lambda-tools-defaults.json
... Info: function handler LinuxFunction::LinuxFunction.Function::FunctionHandler is not defined in config file.
Unknown error occurred causing process exit: Could not load file or assembly 'Amazon.Lambda.Serialization.SystemTextJson, Version=0.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The system cannot find the file specified.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute(Assembly element, Type attributeType)
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunction(LambdaFunctionInfo functionInfo) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 141
at Amazon.Lambda.TestTool.LocalLambdaOptions.LoadLambdaFuntion(LambdaConfigInfo configInfo, String functionHandler) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\LocalLambdaOptions.cs:line 54
at Amazon.Lambda.TestTool.TestToolStartup.LoadLambdaFunction(LambdaConfigInfo configInfo, LocalLambdaOptions localLambdaOptions, CommandLineOptions commandOptions, String lambdaAssemblyDirectory, String lambdaProjectDirectory, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 263
at Amazon.Lambda.TestTool.TestToolStartup.ExecuteWithNoUi(LocalLambdaOptions localLambdaOptions, CommandLineOptions commandOptions, String lambdaAssemblyDirectory, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 131
at Amazon.Lambda.TestTool.TestToolStartup.Startup(String productName, Action`2 uiStartup, String[] args, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 82
(Note that it runs "properly" if the assembly reference (LambdaSerializer) is removed, but obviously that's not a solution)
Any update on this?
I'm using Fedora 31 (so it's seems not to be a Ubuntu issue as @normj suposed) with amazon.lambda.testtool-3.1 (0.10.0) and I tried the same as @JoelRoxell:
dotnet new lambda.EmptyFunction --name LinuxFunction
dotnet restore
dotnet build
dotnet lambda-test-tool-3.1 --no-ui
This is what I get as a response:
=============================================
AWS .NET Core 3.1 Mock Lambda Test Tool (0.10.0)
Loaded local Lambda runtime from project output /home/eric/code/examples/ex005/LinuxFunction/src/LinuxFunction/bin/Debug/netcoreapp3.1
Executing Lambda function without web interface
Found Lambda config file /home/eric/code/examples/ex005/LinuxFunction/src/LinuxFunction/aws-lambda-tools-defaults.json
... Using config file /home/eric/code/examples/ex005/LinuxFunction/src/LinuxFunction/aws-lambda-tools-defaults.json
... Info: function handler LinuxFunction::LinuxFunction.Function::FunctionHandler is not defined in config file.
Unknown error occurred causing process exit: Could not load file or assembly 'Amazon.Lambda.Serialization.SystemTextJson, Version=0.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'. The system cannot find the file specified.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte* ppBlob, Byte pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder
1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute(Assembly element, Type attributeType)
at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunction(LambdaFunctionInfo functionInfo) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 141
at Amazon.Lambda.TestTool.LocalLambdaOptions.LoadLambdaFuntion(LambdaConfigInfo configInfo, String functionHandler) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\LocalLambdaOptions.cs:line 54
at Amazon.Lambda.TestTool.TestToolStartup.LoadLambdaFunction(LambdaConfigInfo configInfo, LocalLambdaOptions localLambdaOptions, CommandLineOptions commandOptions, String lambdaAssemblyDirectory, String lambdaProjectDirectory, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 263
at Amazon.Lambda.TestTool.TestToolStartup.ExecuteWithNoUi(LocalLambdaOptions localLambdaOptions, CommandLineOptions commandOptions, String lambdaAssemblyDirectory, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 131
at Amazon.Lambda.TestTool.TestToolStartup.Startup(String productName, Action`2 uiStartup, String[] args, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 82
=============================================
As @JoelRoxell mentioned, it doesn't happen if I comment the following line of code:
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer))]
... but it turns out I tried the same on a real project and it started to complain about the Serilog:
System.IO.FileNotFoundException: Could not load file or assembly 'Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'. The system cannot find the file specified.
Sounds like it's not finding any dependencies.
Does anyone have any idea what's happening here?
@ericmilaneze Could you try and experiment for me and in your csproj file add the property CopyLocalLockFileAssemblies
with a value of true
and see if that changes your behavior?
Here is a full csproj file example.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="1.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
</ItemGroup>
</Project>
@normj
I'm facing the same issue that @ericmilaneze is facing. Adding mentioned property solved the problem.
Thank you!
It works!
Thanks, @normj!
@normj we are having a similar issue and get exception 'System.IO.FileLoadException' however slightly different stack trace. We tried adding the property above however did not solve the issue. When deployed to AWS this works fine.
We are using the latest test tool for 2.1 but when we use a nuget package that is built for .NET Standard we get the following error:
System.IO.FileLoadException: Could not load file or assembly 'Internal.Integration.Amy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)
at Internal.Inventory.Sync.Lambda.Function..ctor()
---------------- Inner 1 Exception ------------
System.InvalidOperationException: Resolved assembly's simple name should be the same as of the requested assembly.
at System.Runtime.Loader.AssemblyLoadContext.ValidateAssemblyNameWithSimpleName(Assembly assembly, String requestedSimpleName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
Any ideas?
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Adding this worked for me. Can we add this to the README temporarily?
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
this is the only thing that solved my issue
adding the above mentioned property solved the issue for me as well .
Most helpful comment
@ericmilaneze Could you try and experiment for me and in your csproj file add the property
CopyLocalLockFileAssemblies
with a value oftrue
and see if that changes your behavior?Here is a full csproj file example.