2

We have a solution consisting of both .net Framework (4.7.2) and .net Standard (2.0) projects. According to this page: http://docs.servicestack.net/templates-corefx#reference-core-packages we should then only reference the .Core packages. In this case we need ServiceStack.OrmLite and ServiceStack.OrmLite.Mysql, hence I installed ServiceStack.OrmLite.Core and ServiceStack.OrmLite.Mysql.Core. Both on the same 5.4.0 version.

Image: Installed nugets

However, when doing so VS (both 2017 and 2019 p3) will give me compile errors stating (among others, but all of them boils down to the same issue, I think):

The type 'IOrmLiteDialectProvider' exists in both 'ServiceStack.OrmLite, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' and 'ServiceStack.OrmLite, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587'

What we see here is that one of the packages has PublicKeyToken=null while the other one has key 02c12cbda47e6587. What could be the root of my problems here, have I misunderstood what versions of the nugets I should use or are these two packages in the 5.4.0 version incompatible?

(If I install OrmLite.Mysql.Core version 5.2.0 along with OrmLite 5.4.0 the project will compile but fail during runtime since they are referring different versions of Mysql).

Last and least, does anybody know why the .net standard packages are named “core”. To me it was confusing to learn that the core packages can be used in my .net framework projects since .net Core and .net Framework projects are incompatible while both .net Core and .net Framework (of course) can use .net Standard.

Erik Lindberg
  • 125
  • 1
  • 7

1 Answers1

0

This Exception indicates you have a project that tries to reference both the ServiceStack.OrmLite and ServiceStack.OrmLite.Core packages in the same project which you should never be doing.

Please read this existing answer carefully, the .Core packages should only be referenced when trying to Run ASP.NET Core Apps on the .NET Framework, but at no point can you ever have projects that reference both .Core and non .Core packages together, the only way you can share dependencies between different platforms is by multi-targeting.

You can find an example of a solution which shares common multi-targeted project from:

https://github.com/ServiceStackApps/HelloMobile#servicestack-server-app

This shows an example of how multiple hosts are able to share the same Server.Common and ServiceModel.csproj projects by multi-targeting:

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

Where the .NET Core and ASP.NET Core on .NET Framework will end up using the netstandard2.0 builds of the common projects whilst the classic ASP.NET and HttpListener Hosts will end up using the net46 builds.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • 1
    I only have two ServiceStack packages; Ser...OrmLite.Core and Ser...OrmLite.Mysql.Core (in the same .net Framework project) When I'm running both on 5.4.0 I get the error in my previous post. When I change the Ser...OrmLite.Mysql.Core to 5.2.0, it compiles but then fail during runtime since the mysql ref. inside these packages differs. So as far as I understand I'm past the problem of selecting the right kind of package. However, I cant find two packages that can run together. Both on 5.4.0 will give me the compile errors, trying different versions will give me runtime errors. – Erik Lindberg Feb 18 '19 at 08:52
  • @ErikLindberg You should never be referencing both packages, either you're running ASP.NET Core on .NET Fx in which case you should only be using `*.Core` packages otherwise for any other project you should not be referencing any `.Core` packages. If you're still getting this error then I'm assuming you've got a dirty project, delete all `/bin` and `/obj` folders then do a full restore + build. – mythz Feb 18 '19 at 09:08
  • 1
    But I'm not! Se the image in my original post, the only two ServiceStack packages I reference are of type ...Core. I asked a colleague to switch from his working setup (ServiceStack.OrmLite and ServiceStack.OrmLite.Mysql) to ServiceStack.OrmLite.Core and ServiceStack.OrmLite.Mysql.Core (5.4.0). And he got the exakt same compiler errors. Are you sure ServiceStack.OrmLite.Core and ServiceStack.OrmLite.Mysql.Core are compatible in 5.4.0? We cannot get them to compile together when using ServiceStack.OrmLite.IOrmLiteDialectProvider. – Erik Lindberg Feb 18 '19 at 14:25
  • 1
    @ErikLindberg Apologies [OrmLite.MySql.Core v5.4.0](https://www.nuget.org/packages/ServiceStack.OrmLite.MySql.Core) was referencing the wrong OrmLite instead of OrmLite.Core dependency, you'll need to use [v5.4.1 on MyGet](https://docs.servicestack.net/myget) to install the OrmLite.MySql.Core package that references OrmLite.Core. – mythz Feb 18 '19 at 18:07
  • Was starting to doubt my understanding of it all there for a second :) Thanks for the new packages, they seem to work and get me past this problem to the next one :) – Erik Lindberg Feb 19 '19 at 09:09