v5 ServiceStack Clients (with Net Standard/Core 2.0)

Currently working on a new version of a solution. I thought I’d jump in and use .NET Core 2.0 and v5 for the backend code so it’s portable amongst different operating systems.

My problem is that when I attempt to use the .NET JsonServiceClient in my test program (.Net Framework 4.6.1), I get an error message stating a reference is required to ServiceStack.Interfaces 5.0.0. I tried to change it to use ServiceStack.Client.Core however I then get an exception that a method is missing in HttpUtils.

Breakdown of frameworks:

Main Service: .NET Core 2.0 (runs fine)
ServiceModel: .NET Standard 2.0 (seems to be fine)
Test Program: .NET Framework 4.6.1 (has issues)

Is this even possible? It’s new to me all these variations! Thanks for your time.

Ok, just to update. I’ve managed to fix the first part about reference being required.

However, I’m still getting the following message when I attempt to perform a [get] transaction on the service:

Method not found: ‘Boolean ServiceStack.HttpUtils.HasRequestBody(System.String)’.

Can you try clearing your NuGet cache and trying again:

$ nuget locals all -clear

If that doesn’t resolve it, can you delete your /bin and /obj folders as well.

I’ve checked the ServiceStack.Text.dll in both ServiceStack.Text and ServiceStack.Text.Core packages and they all have a HttpUtils.HasRequestBody(string httpMethod) defined so I’m assuming you’re using an old .dll somewhere.

Ok, I cleared the cache and I started to get another error message about mismatch and PUBLIC KEY TOKEN.

I worked out I needed to use the ServiceStack.Client.Core package to work with the .Net standard ServiceModel projects I had. However, I can’t seem to find a way to use MsgPack with the core packages? The core package seems to be deprecated and the normal ServicePack.MsgPack wants to bring the non-working libraries.

Am I missing something? Really sorry, this core/standard stuff is all very new to me!

There is no .NET Standard only .Core package for MsgPack, they only exist for the ServiceClient projects. You’ll either need to remove the binary coupling by using the source-only copy of your DTOs with Add ServiceStack Reference or have the Service Model projects create .NET Standard + .NET Framework builds with:

<PropertyGroup>
    <TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
</PropertyGroup>

Then you’ll be able to use the main ServiceStack.Client + ServiceStack.MsgPack packages.

FYI as they can be used in ServiceClients I’ve added .NET Standard 2.0 NuGet packages for MsgPack and ProtoBuf:

  • ServiceStack.MsgPack.Core
  • ServiceStack.ProtoBuf.Core

Which is available from v5.0.1 that’s now on MyGet.

Hello,
I am getting same error (Missing reference on ServiceStack.Interfaces 5.0.0) when trying to reference .net Standard 2.0 from .Net 4.6.1 framework.
I tried to clear nuget cache but still the same error.

.net standard csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
  </PropertyGroup>    
</Project>

Please help.

Please make sure you’ve read this thread and the docs on what’s supported, i.e. a you can force the reference of .NET Standard client packages from .NET Framework, but you can’t run .NET Standard Server libraries from .NET Framework.

Also when you target multiple frameworks like:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
  </PropertyGroup>    
</Project>

You’re not “trying to reference .net Standard 2.0 from .Net 4.6.1 framework” you’re creating 2 separate builds, where the net461 framework build will be referencing .NET Framework versions and the netstandard2.0 build will be referencing .NET Standard versions.