Changing to JsonHttpClient causes MethodNotFound error

As part of some code clean up we changed the client from the JsonServiceClient to the newer JsonHttpClient. Nothing else was changed in the client of server service.

When calling a simple GetAsync with JsonServiceClient, all works as expected. When using the JsonHttpClient I receive the following error.

System.MissingMethodException: ‘Method not found: ‘System.String ServiceStack.UrlExtensions.ToUrl(System.Object, System.String, System.Func`2<System.Type,System.String>)’.’

My client code is very simple.

public async Task PullRates()
{
const string url = “https://service.abc.com/”;

    var client = new JsonHttpClient(url);

    var reqdCurrencies = GetRequiredCurrencies();

    return await client.GetAsync(new GetRates{ BaseCurrency = _settings.BaseCurrency, RequiredCurrencies = reqdCurrencies });

}

Am I doing something wrong? If so, what?

FYI, we are using .Net 6 in this project.

Anytime you see a missing type or missing method exceptions when using the MyGet pre-release packages it means you have a dirty installation (i.e. using pre-release packages from different build times).

In which case you’d need to Clear your Nuget packages cache and download the latest packages again, which ensures all your packages are from the latest same build:

$ dotnet nuget locals all -clear