1

I have a full framework .NET 4.7.2 (also tried 4.6.1) class library that references ServiceStack 4.5.8.0. When attempting to upgrade to ServiceStack 5.5.0, I get the following compile-time error:

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

and

Argument 1: cannot convert from 'MyRadNameSpace.MySweetClass' to 'ServiceStack.IReturnVoid

There is a related question, but the question revolves around using .NET Standard and .NET core, whereas this library targets the full framework.

How can I troubleshoot this issue?

Noel
  • 3,288
  • 1
  • 23
  • 42
  • 1
    It sounds like you've got a transitive dependency to the wrong ServiceStack.Interfaces package, does this project reference a .NET Standard library which references a ServiceStack package? As that will conflict with the .NET Fx ServiceStack.Interfaces package your project needs. – mythz Jul 03 '19 at 23:23
  • There are quite a few transitive dependencies on projects that target both .NET standard and .NET Full Framework. I would assume that the .NET Full framework would be used. In some cases, however, the dependencies that target .NET Full Framework depend on `ServiceStack.Interfaces (>= 4.5.8)` whereas the version of that package targeting .NET Standard depend on `ServiceStack.Interfaces (>= 5.1.0)`. Maybe the project is using the .NET standard version because my project depends on ServiceStack 5.x? Any thoughts on how to verify that? – Noel Jul 05 '19 at 13:17
  • You cannot mix and match .NET Framework and .NET Standard projects that reference different builds from ServiceStack packages, you'll need to multi-target your .NET Standard dependencies to also provide .NET Framework builds. – mythz Jul 05 '19 at 13:23
  • Sorry if that wasn't clear - the dependent packages are multi-targeting .NET Framework and .NET Standard. The .NET Framework version of the dependencies shows a dependency on `ServiceStack.Interfaces (>= 4.5.8)`, so I would expect `5.x` in my project to work. – Noel Jul 05 '19 at 14:27
  • The error suggests you still have a dependency that's referencing the wrong ServiceStack.Interfaces build. Note all dependencies should be referencing the same version version number for all ServiceStack packages, i.e. they all should be referencing the same `5.x` version. You can also try deleting the `/bin` and `/obj` folders to force a clean restore/build. – mythz Jul 05 '19 at 19:52
  • 1
    I think you're right, I was initially chasing the .NET Standard vs. NET Full framework, but it looks like simply a version mismatch issue between dependencies and the project. The dependent projects have dependencies that rely on ServiceStack (the dependency tree is deep). If you want to move your comment to an answer, I'll accept it. Thanks for your help! – Noel Jul 05 '19 at 20:21

1 Answers1

1

The error suggests you still have a dependency that's referencing an incompatible ServiceStack.Interfaces build. This is typically due to having dependencies that reference both .NET Framework and .NET Standard builds of ServiceStack packages within the same project in which case you'll need to multi-target your .NET Standard projects.

It could also be due to a version mismatch. Note all dependencies should be referencing the same version version number for all ServiceStack packages, i.e. they all should be referencing the same 5.x version. You can also try deleting the /bin and /obj folders to force a clean restore and build.

mythz
  • 141,670
  • 29
  • 246
  • 390