0

ターゲット フレームワークとして .net core 3 (プレビュー 9) を使用し、新しい System.text.json 名前空間を使用する関数を実装しようとしています。これが私のコードです:

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using System.Text.Json;

namespace Backtester
{
    public class Test
    {
        public string Author { get; set; }
        public string Currency { get; set; }
    }

    public static class Function
    {
        [FunctionName("Function")]
        public static void Run([ServiceBusTrigger("%QueueName%", Connection = "AzureWebJobsServiceBus")]string myQueueItem, ILogger log)
        {
            try
            {
                var request = JsonSerializer.Deserialize<Test>(myQueueItem);
                log.LogInformation($"Currency: {request.Currency} - {request.Author}");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}

コードを実行して Service Bus キューにメッセージを送信すると、関数はトリガーされますが、次のエラーで失敗します。

[13/09/2019 13:01:25] System.Private.CoreLib: Exception while executing function: Function. Backtester: Could not load file or assembly 'System.Text.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058). Cannot load a reference assembly for execution.
[13/09/2019 13:01:25] MessageReceiver error (Action=UserCallback, ClientId=MessageReceiver1********************, EntityPath=**********, Endpoint=**********************************)
[13/09/2019 13:01:25] System.Private.CoreLib: Exception while executing function: Function. Backtester: Could not load file or assembly 'System.Text.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058). Cannot load a reference assembly for execution.

プロジェクトを .net core 2.2 にダウングレードする必要があるという結論に達しました。新しいコードベースを使用して Web プロジェクトを立ち上げて実行しているため、かなりの作業が必要になります。

4

1 に答える 1