Search code examples
servicestackservice-model

How can I use a Service Model from ServiceStack 4.0 in a ServiceStack 5.0 Project?


I have begun the process of migrating one of our many ServiceStack services from .Net Framework to .Net core. Most of the migration has been relatively smooth, but I have run into a brick wall with Service Models. This service is dependent on using other ServiceStack services that are still on version 4.0. When I attempt to use Service Models from those services in the new project I get an error saying that the IReturn<> interface wants the version 4.0 assembly specifically, and does not want the 5.0 version of ServiceStack.Interfaces. Downgrading just ServiceStack.Interfaces causes a similar error, but the inverse where everything else that depends on that assembly wants version 5.0. Is there a way to upgrade one project without upgrading every project? I think we all know that real systems need a transition period, and that there's just no way to migrate every service simultaneously.


Solution

  • Please read the existing links from this answer:

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

    TL;DR you can’t share the same .dll, you either need to multi-target or decouple the binary dependency by using C# Add ServiceStack Reference.

    Other solutions is having old Framework projects Reference the old compiled ServiceModell.dll (alternative to multi targeting) or just copy the source code of the DTOs you need (alternative to C# Add ServiceStack Reference).