2

We recently created a new DotNetCore web service using ServiceStack. The ServiceModel project is a DotNet Standard class library v2.0.

I am getting compiling errors while referencing the new ServiceModel from our existing web services that were written in DotNet Framework 4.6.1. Looks like by referencing the new ServiceModel, it is pulling in ServiceStack.Interfaces.Core which conflict with ServiceStack.Interfaces already referenced in the DotNet Framework project.

We are not looking to upgrade those existing services to DotNetCore yet. Is there a way to consume a DotNet Standard ServiceModel in a DotNet Framework web service?

[Edit 1]

Found a similar issue here. My ServiceModel only references ServiceStack.Interfaces.Core(5.1.0). The .net Framework project is targeting v4.6.1 and using ServiceStack v4.5.8. Do I need to upgrade to the latest Service Stack to make it work?

[Edit 2]

Upgraded the ServiceStack version to 5.1.0 in the .net Framework project. That fixed those Service not implementing IServiceClient errors. However, now I am getting

  • The type 'IReturn<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null'.

  • The type arguments for method 'IServiceGateway.Send(object)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

CoffeeAddict
  • 23
  • 1
  • 3

1 Answers1

1

If you want to support both classic ASP.NET Framework project and a .NET Core project you need to multi target. See this previous answer for details:

https://stackoverflow.com/a/49417944/85785

If you just want to support an ASP.NET Core .NET Framework project and a .NET Core project (I.e. both ASP.NET Core projects) you can reference ServiceStack’s *.Core projects which only contains .NET Standard builds.

Alternatively you can avoid the binary coupling of sharing your ServiceModel.dll project and have the classic ASP.NET projects reference your DTOs via C# Add ServiceStack Reference.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • When you said I need to "reference ServiceStack's *.Core" packages", you mean the project that will consume the ServiceModel need to reference those? – CoffeeAddict Jul 09 '18 at 22:36
  • @CoffeeAddict I literally mean [ServiceStack’s .Core packages](http://docs.servicestack.net/templates-corefx#reference-core-packages) to force the ASP.NET Core Framework projects to Reference the same .NET Standard 2.0 builds as .NET Core projects. – mythz Jul 10 '18 at 00:04
  • I tried to understand the content in that link above. My understanding is a .NET Framework 4.6.1 project should be able to just use a .NET Standard code library dll. The linked text said you re-published .Core Nuget packages which contains only the .NET standard 2.0 builds so .NET Framework projects can consume it. Which make sense. My ServiceModel is a .NET Standard library only references ServiceStack.Interfaces.Core (which is a .NET Standard library). So my 4.6.1 version of .NET Framework ASP.NET application should be able to consume it? What am I missing here? – CoffeeAddict Jul 10 '18 at 00:49
  • @CoffeeAddict No, please read my [linked answer very carefully](https://stackoverflow.com/a/49417944/85785) a classic ASP.NET Framework project needs to multi-target, only **ASP.NET Core** Framework projects can avoid multi-targeting by referencing the `*.Core` packages. My answer explains the only 2 options available if you're trying to call a ASP.NET Core project from a v4.6.1 project, namely Multi Target or use C# Add ServiceStack Reference. – mythz Jul 10 '18 at 01:24