8000 [BUG] Error during runtime "<interfacename> doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project" · Issue #1085 · reactiveui/refit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[BUG] Error during runtime "<interfacename> doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project" #1085
Closed
@rezanid

Description

@rezanid

I have an interface like the following.

using Refit;
using System.Threading.Tasks;

namespace MyNamespace
{
    public interface IUserApi
    {
        [Get("/api/user/getuser")]
        Task<UserModel.User> GetUserAsync(string userID);
    }
}

Elsewhere in the following like I get an exception during runtime.

var userService = RestService.For<IUserApi>(httpClient);

The exception is as following.

[InvalidOperationException: IUserApi doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project.]
    Refit.RestService.GetGeneratedType(Type refitInterfaceType) +106
    Refit.RestService.For(Type refitInterfaceType, HttpClient client, IRequestBuilder builder) +38
    Refit.RestService.For(HttpClient client, IRequestBuilder`1 builder) +66
    Refit.RestService.For(HttpClient client, RefitSettings settings) +86
    Refit.RestService.For(HttpClient client) +42

What can be wrong? How can I troubleshoot this kind of issue?

Environment

  • Visual Studio 2019 v. 16.8.5
  • Refit v. 6.0.15
  • .NET Framework 4.7.2

Additional context
I have just installed Refit using its official NuGet and it is the first time the library is being used in the project. I have used Refit several time in the past and never had this kind of issue.
When I check in the obj\Debug folder of the project, the RefitStubs.g.cs file is missing, but the build is successful and I don't get any errors or relevant warning during build (even in detailed verbosity).

Workaround
Downgrading Refit to v. 5 fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0