英文:
Cannot find AddRefitClient method for Worker Service
问题
I understand your request. Here's the translated content:
目前我正在使用.NET 7版本来执行后台作业服务。我添加了Worker Service项目,在Program.cs
文件中,虽然我添加了Refit
包来调用API,但我无法调用AddRefitClient
方法。我不想使用HttpClient。
这是错误信息:
'IServiceCollection' 不包含名称为 'AddRefitClient' 的定义,并且找不到接受类型为 'IServiceCollection' 的第一个参数的可访问扩展方法 'AddRefitClient'(您是否缺少使用指令或程序集引用?)
英文:
Currently I using .NET version 7 to do background job service. I add Worker Service project, in Program.cs
file I cannot call method AddRefitClient
although I add package Refit
to call API. I don't want to use HttpClient
This is error message:
> '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?)
答案1
得分: 5
你还需要安装Refit.HttpClientFactory包。
英文:
You also need the package Refit.HttpClientFactory to install.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论