Aws-lambda-dotnet: Testtool: Interner Serverfehler: FileNotFoundException: Datei oder Assembly konnte nicht geladen werden

Erstellt am 6. März 2020  ·  19Kommentare  ·  Quelle: aws/aws-lambda-dotnet

Es scheint, als hätte ich ein Problem, auf das andere nicht stoßen. Ich habe alles überprüft, was mir einfällt, aber egal, was ich tue, wenn das Lambda-Testtool im Browser geöffnet wird, kann es die Funktionsliste nicht laden.

Auf der Registerkarte Netzwerk sehe ich:

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)

Ist jemand schon mal darauf gestoßen oder kann mich in die richtige Richtung weisen? Es gibt keine Fehler in der Konsole, wenn ich sie ausführe, und ich bin mir nicht ganz sicher, wo es schief geht.

Erwähnenswert ist vielleicht, dass ich dies auf Ubuntu betreibe.

Lambda-Test-Tool dependencies feature-request modullambda-test-tool

Hilfreichster Kommentar

@ericmilaneze Könnten Sie versuchen und für mich experimentieren und in Ihrer csproj-Datei die Eigenschaft CopyLocalLockFileAssemblies mit einem Wert von true hinzufügen und sehen, ob sich dadurch Ihr Verhalten ändert?

Hier ist ein vollständiges csproj-Dateibeispiel.

<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>

Alle 19 Kommentare

Ich arbeite an einer neuen Version dieses Tools, die mit der kommenden .NET Core 3.1-Version verknüpft ist, aber auch weiterhin .NET Core 2.1 unterstützt. Ich habe einige Überarbeitungen vorgenommen, wie der Lambda-Code geladen wird. Wenn ich einen Link zu einem Vorschau-Build bereitstellen würde, wären Sie bereit, es auszuprobieren.

@normj auf jeden Fall, wenn es abwärtskompatibel mit 2.1 ist, da ich idealerweise noch nicht alle meine Funktionen überarbeiten möchte 😅

Ja, in Zukunft gab es zwei separate Tools, eines für 2.1 und eines für 3.1, aber sie werden viel von der gleichen Logik haben. Lassen Sie mich die Dinge aufräumen und dann füge ich einen Link zur Version 2.1 hinzu.

Geschätzt danke

Hier ist ein Link zu einem Preview-Build der kommenden Version.

https://normj-packages.s3.us-west-2.amazonaws.com/Amazon.Lambda.TestTool-2.1.0.10.0-preview1.nupkg

Um es zu installieren, laden Sie die nupkg-Datei herunter. Führen Sie dann in dem Verzeichnis, in das Sie die Datei herunterladen, den folgenden Befehl aus, um Ihre vorhandene Version zu aktualisieren.

dotnet tool update -g amazon.lambda.testtool-2.1 --version 0.10.0-preview1 --add-source .

Wir hatten Probleme mit 0.9.5, die die netstandard20-Version des NuGet-Pakets Microsoft.AspNet.WebApi.Client nicht geladen haben. Durch die Aktualisierung auf die Vorschauversion 0.10.0 wurde unser Problem behoben.

@brandon-king-halo Danke, dass du mich wissen lässt, dass die Vorschau 0.10.0 das Problem behebt!

Entschuldigung, ich hatte noch keine Gelegenheit, dies zu testen. Ich sollte es mir diese Woche anschauen können!

FYI Wenn jemand Probleme hat, nupkg lokal zu installieren. Lauf:

dotnet tool uninstall -g amazon.lambda.testtool-2.1

Und dann ausführen:

dotnet tool install -g amazon.lambda.testtool-2.1 --version 0.10.0-preview1 --add-source .


@normj
Ich bekomme immer noch die gleiche Ausnahme mit der Vorschauversion:

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)

Sie haben erwähnt, dass Sie dies unter Ubuntu tun. Haben Sie die gleiche Lösung auf etwas anderem als Ubuntu versucht? Ich frage mich, ob dies ein plattformspezifisches Problem ist.

Könnte verwandt sein, versucht, mit 3.1 und dem entsprechenden Testtool unter Ubuntu 19.10 ausgeführt zu werden.

  1. dotnet new lambda.EmptyFunction --name LinuxFunction
  2. dotnet restore
  3. dotnet build
  4. dotnet lambda-test-tool-3.1 --no-ui

entsorgen:

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

(Beachten Sie, dass es "richtig" läuft, wenn die Assembly-Referenz (LambdaSerializer) entfernt wird, aber das ist offensichtlich keine Lösung.)

Gibt es hierzu Neuigkeiten?

Ich verwende Fedora 31 (es scheint also kein Ubuntu-Problem zu sein, wie @normj vermutet) mit amazon.lambda.testtool-3.1 (0.10.0) und ich habe dasselbe wie @JoelRoxell versucht:

  1. dotnet new lambda.EmptyFunction --name LinuxFunction
  2. dotnet restore
  3. dotnet build
  4. dotnet lambda-test-tool-3.1 --no-ui

Das bekomme ich als Antwort:

===========================================

AWS .NET Core 3.1 Mock-Lambda-Testtool (0.10.0)
Geladene lokale Lambda-Laufzeit aus der Projektausgabe /home/eric/code/examples/ex005/LinuxFunction/src/LinuxFunction/bin/Debug/netcoreapp3.1
Ausführen der Lambda-Funktion ohne Webschnittstelle
Lambda-Konfigurationsdatei /home/eric/code/examples/ex005/LinuxFunction/src/LinuxFunction/aws-lambda-tools-defaults.json gefunden
... Verwenden der Konfigurationsdatei /home/eric/code/examples/ex005/LinuxFunction/src/LinuxFunction/aws-lambda-tools-defaults.json
... Info: Funktionshandler LinuxFunction::LinuxFunction.Function::FunctionHandler ist nicht in der Konfigurationsdatei definiert.
Unbekannter Fehler beim Beenden des Prozesses: Datei oder Assembly „Amazon.Lambda.Serialization.SystemTextJson, Version=0.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604“ konnte nicht geladen werden. Die angegebene Datei wurde vom System nicht gefunden.

bei System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType Typ, IRuntimeMethodInfo pCtor, Byte * ppBlob, Byte pEndBlob, Int32* pcNamedArgs)
bei System.Reflection.CustomAttribute.CreateCaObject (RuntimeModule-Modul, RuntimeType-Typ, IRuntimeMethodInfo-Ctor, IntPtr& Blob, IntPtr BlobEnd, Int32& namedArgs)
bei System.Reflection.CustomAttribute.AddCustomAttributes (ListBuilder 1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder 1 abgeleiteteAttribute)
bei System.Reflection.CustomAttribute.GetCustomAttributes (Laufzeitmodul dekoriertes Modul, Int32 dekoriertesMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
bei System.Reflection.CustomAttribute.GetCustomAttributes (RuntimeAssembly-Assembly, RuntimeType caType)
bei System.Reflection.RuntimeAssembly.GetCustomAttributes (Type attributeType, Boolean erben)
bei System.Attribute.GetCustomAttributes (Assembly-Element, Type attributeType, Boolean erben)
bei System.Attribute.GetCustomAttribute (Assembly-Element, Type attributeType, Boolean erben)
bei System.Reflection.CustomAttributeExtensions.GetCustomAttribute (Assembly-Element, Typ attributeType)
bei Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.LoadLambdaFunction(LambdaFunctionInfo functionInfo) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs: Zeile 141
bei Amazon.Lambda.TestTool.LocalLambdaOptions.LoadLambdaFuntion(LambdaConfigInfo configInfo, String functionHandler) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\LocalLambdaOptions.cs: Zeile 54
bei 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: Zeile 263
bei 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:Zeile 131
bei 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:Zeile 82

===========================================

Wie @JoelRoxell erwähnte, passiert es nicht, wenn ich die folgende Codezeile kommentiere:
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer))]

... aber es stellte sich heraus, dass ich dasselbe bei einem echten Projekt ausprobiert hatte und es begann, sich über das Serilog zu beschweren:

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.

Klingt so, als würde es keine Abhängigkeiten finden.

Hat jemand eine Ahnung, was hier passiert?

@ericmilaneze Könnten Sie versuchen und für mich experimentieren und in Ihrer csproj-Datei die Eigenschaft CopyLocalLockFileAssemblies mit einem Wert von true hinzufügen und sehen, ob sich dadurch Ihr Verhalten ändert?

Hier ist ein vollständiges csproj-Dateibeispiel.

<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
Ich stehe vor dem gleichen Problem wie @ericmilaneze . Das Hinzufügen der erwähnten Eigenschaft löste das Problem.
Danke schön!

Es klappt!

Danke, @normj!

@normj Wir haben ein ähnliches Problem und erhalten die Ausnahme „System.IO.FileLoadException“, jedoch einen etwas anderen Stack-Trace. Wir haben versucht, die obige Eigenschaft hinzuzufügen, haben das Problem jedoch nicht gelöst. Bei der Bereitstellung auf AWS funktioniert dies einwandfrei.

Wir verwenden das neueste Testtool für 2.1, aber wenn wir ein Nuget-Paket verwenden, das für .NET Standard erstellt wurde, erhalten wir die folgende Fehlermeldung:

System.IO.FileLoadException: Datei oder Assembly „Internal.Integration.Amy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null“ konnte nicht geladen werden. Eine Operation ist im jetzigen Zustand nicht legal. (Ausnahme von HRESULT: 0x80131509)
bei Internal.Inventory.Sync.Lambda.Function..ctor()
---------------- Innere 1 Ausnahme ------------
System.InvalidOperationException: Der einfache Name der aufgelösten Assembly sollte mit dem der angeforderten Assembly identisch sein.
bei System.Runtime.Loader.AssemblyLoadContext.ValidateAssemblyNameWithSimpleName (Assembly-Assembly, Zeichenfolge angefordertSimpleName)
bei System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad (AssemblyName AssemblyName)
bei System.Runtime.Loader.AssemblyLoadContext.Resolve (IntPtr gchManagedAssemblyLoadContext, AssemblyName AssemblyName)

Irgendwelche Ideen?

 <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

Das Hinzufügen hat bei mir funktioniert. Können wir dies vorübergehend zur README hinzufügen?

    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

Dies ist das einzige, was mein Problem gelöst hat

Das Hinzufügen der oben genannten Eigenschaft löste das Problem auch für mich.

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen