Aws-lambda-dotnet: [aws-lambda-dotnet]アセンブリを読み込めませんでした

作成日 2018年12月15日  ·  6コメント  ·  ソース: aws/aws-lambda-dotnet

やあ、
AWS .NET Mock Lambda Test Toolを実行しようとすると、エラーが発生します。
アセンブリを読み込めませんでしたNLog.AWS.Logger.dll
テストを実行すると、すべて正常に機能します。
すべてのdllをnugetパッケージから出力にコピーしようとしましたが、エラーが続行します。
エラーは、実行中にラムダのNLogを構成する関数で発生します(localhost:5050の実行関数ボタンを呼び出します)

 public virtual void Init(ILambdaContext context)
        {
            this.ConfigureNLog(context);  // <----- ERROR WHEN CALLLING
            Log = LogManager.GetCurrentClassLogger();
            InitIoC();
        }
  internal void ConfigureNLog(ILambdaContext context)
        {
            var config = new LoggingConfiguration();

            var consoleTarget = new ColoredConsoleTarget();
            config.AddTarget("console", consoleTarget);
            var jsonLayout = new JsonLayout
            {
                Attributes =
    {
                    new JsonAttribute("time", "${longdate}"),
                    new JsonAttribute("level", "${level:upperCase=true}"),
                    new JsonAttribute("message", "${message}"),
                    new JsonAttribute("type", "${exception:format=Type}"),
                    new JsonAttribute("message", "${exception:format=Message}"),
                    new JsonAttribute("stacktrace","${stacktrace:format=raw"),
                    new JsonAttribute("innerException", new JsonLayout
                    {

                        Attributes =
                        {
                            new JsonAttribute("type", "${exception:format=:innerFormat=Type:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}"),
                            new JsonAttribute("message", "${exception:format=:innerFormat=Message:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}"),
                        },
                          RenderEmptyObject = false
                    },

        false)
    }
            };


            var awsTarget = new AWSTarget()
            {
                LogGroup = context.LogGroupName,
                Region = context.ClientContext.Environment["AWS_DEFAULT_REGION"],
                Layout = jsonLayout
            };

            config.AddTarget("aws", awsTarget);
            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, consoleTarget));
            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, awsTarget));

            LogManager.Configuration = config;
        }
guidance

最も参考になるコメント

こんにちは、みんな、
@Kralizek @normj
問題を理解するためにしばらく時間を費やした後、私はついにそれを理解しました。
2.2バージョンのEFコアや構成のようないくつかのパッケージがありました。
共有フレームワーク(Microsoft.NetCore.App)は.NEt Core 2.1であるため、%program files%\ dotnet \ shared \ Microsoft.AspNetCore.App\2.1.6からDllをロードします。
このフォルダーには、EFCoreおよびConfigurationsDLLバージョン2.1。*が含まれているため、パッケージを2.1。*バージョンに変更した後は、正常に機能しました。
Microsftは、Microsoft.NetCore.App 2.1を使用する場合は、これを正確に推奨します。2.1。*を使用してください。

一番

デリオ

全てのコメント6件

問題を報告していただきありがとうございます。 csprojファイルを投稿して、ソリューションのレイアウトを説明できる可能性はありますか?

こんにちは@normj 、長い遅延をお詫び申し上げます。 私は休暇中でした。
私のCSPROJの下:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <AWSProjectType>Lambda</AWSProjectType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Amazon.Lambda.Core" Version="1.0.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.4.0" />
    <PackageReference Include="AWS.Logger.NLog" Version="1.3.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
    <PackageReference Include="NLog" Version="4.5.11" />
    <PackageReference Include="SimpleInjector" Version="4.4.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\App.AppService\App.AppService.csproj" />
    <ProjectReference Include="..\App.Data\App.Data.csproj" />
    <ProjectReference Include="..\App.Infra\App.Infra.csproj" />
  </ItemGroup>

  <ItemGroup>
    <None Update="appsettings.Development.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="appsettings.Debug.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>appsettings.json</DependentUpon>
    </None>
    <None Update="appsettings.json">
      <TransformOnBuild>true</TransformOnBuild>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="appsettings.Release.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>appsettings.json</DependentUpon>
    </None>
    <None Update="appsettings.Test.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Integrations\" />
  </ItemGroup>

</Project>

一番

.NET Core 2.2はLambdaでサポートされていないため、 .netcoreapp2.1を使用するように関数を変更してみてください:)

すでに2.1に変更しました。
同じエラーが続きます。

こんにちは、みんな、
@Kralizek @normj
問題を理解するためにしばらく時間を費やした後、私はついにそれを理解しました。
2.2バージョンのEFコアや構成のようないくつかのパッケージがありました。
共有フレームワーク(Microsoft.NetCore.App)は.NEt Core 2.1であるため、%program files%\ dotnet \ shared \ Microsoft.AspNetCore.App\2.1.6からDllをロードします。
このフォルダーには、EFCoreおよびConfigurationsDLLバージョン2.1。*が含まれているため、パッケージを2.1。*バージョンに変更した後は、正常に機能しました。
Microsftは、Microsoft.NetCore.App 2.1を使用する場合は、これを正確に推奨します。2.1。*を使用してください。

一番

デリオ

問題を解決できてよかったです。

このページは役に立ちましたか?
0 / 5 - 0 評価