Visual Studio .NET Standard library and .NET Framework project - NuGet dll manifest definition does not match

1

I use VS 2019, I have a .NET Standard (2.0) library project named Foo (using ServiceStack NuGet package) and a main .NET Framework (4.7.2) windows service project named Bar (also using ServiceStack NuGet). Bar has a reference to Foo. Bar is a windows service and a ServiceStack REST host, Foo has the DTOs shared across solutions (it needs ServiceStack library for the [Route] attribute).

When I try to run any ServiceStack-related code in Bar, I get:

{"Could not load file or assembly 'ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null"} System.IO.FileLoadException

Despite having this entry in Bar's app.config (I use the publicKeyToken from Bar's .csproj):

  <dependentAssembly>
    <assemblyIdentity name="ServiceStack.Interfaces" publicKeyToken="02c12cbda47e6587" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>

How can I make those two work together?

Edit:

Both ServiceStack NuGet packages in Foo and Bar have version 5.5.0 (the .NET Framework's .dll "version" as seen in VS properties is 5.0.0.0). I have tried with and without a publicKeyToken, I've tried mapping oldVersion="0.0.0.0-5.5.0.0" newVersion="5.0.0.0" and oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0".

The actual .dll in the output folder has this full name: ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587

c#
.net
visual-studio
nuget
.net-standard
asked on Stack Overflow Jul 19, 2019 by user1713059 • edited Jul 19, 2019 by user1713059

1 Answer

0

You can search for "ServiceStack multi-target" to view answers that address this issue like this answer.

In summary, if you only want to Run ASP.NET Core Apps on the .NET Framework you can only reference .Core packages otherwise if you want to be able to mix both .NET Standard and .NET Framework projects together in the same solution you need to multi-target.

answered on Stack Overflow Jul 19, 2019 by mythz

User contributions licensed under CC BY-SA 3.0