Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to cast object when initialising interface #1125

Open
marwahaks opened this issue Mar 17, 2021 · 1 comment
Open

[BUG] Unable to cast object when initialising interface #1125

marwahaks opened this issue Mar 17, 2021 · 1 comment
Labels

Comments

@marwahaks
Copy link

Describe the bug
What am I trying to do: Connect to an api and retrieve data.

In my Test Solution Project, which i have converted from .Net Framework to .Net 5, it gives me this error.
Unable to cast object of type 'UIHelpersRestClientRefitBugIWoofClient' to type 'UI.Helpers.RestClient.RefitBug.IWoofClient.
To diagnose, I've made a standalone project and this works perfectly (same code), so I know this may not be a bug or even a straightforward bug.

namespace UI.Helpers.RestClient.RefitBug
{
    interface IWoofClient
    {
        [Refit.Get("/woof.json")]
        Task<WoofResponseObject> GetDawg();
    }
}

 public WoofClient()
        {
            _baseUrl = new Uri("https://random.dog/");

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            {
			//below is where the error occurs
                IWoofClient = Refit.RestService.For<IWoofClient>(
                new HttpClient()
                {
                    BaseAddress = _baseUrl
                });
            }
        }

As I mentioned, this works in the Test Solution that is using .Net Framework.

Environment

OS: Win 10
Visual Studio Pro 16.9.1
.Net 5
Package Version: 6.0.24

@marwahaks marwahaks added the bug label Mar 17, 2021
@clairernovotny
Copy link
Member

I'm going to need a more concrete repro for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants