找不到 Worker Service 的 AddRefitClient 方法

Tru*_*ruc 3 .net refit worker-service

目前我使用 .NET 版本 7 来做后台作业服务。我添加了 Worker Service 项目,在Program.cs文件中我无法调用方法AddRefitClient,尽管我添加了包Refit来调用 API。我不想使用 HttpClient

这是错误消息:

'IServiceCollection' does not contain a definition for 'AddRefitClient' and no accessible extension method 'AddRefitClient' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

在此输入图像描述

Abu*_*ids 11

您还需要安装Refit.HttpClientFactory包。