Upgraded ServiceStack.OrmLite.SqlServer. Getting an error about System.Text.Encoding.CodePages now

2

I inherited a project that was written in .NetCore 2.0 initially. The version of ServiceStack.OrmLite.SqlServer.Core that we were using was 1.0.43. I upgraded everything in NuGet, so ServiceStack is now 5.4.0.

The problem now is that when I try to run my code:

var dbFactory = new OrmLiteConnectionFactory(dbConnection.ConnectionString, SqlServerDialect.Provider);
using (var db = dbFactory.Open())

I get an error

System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I see in the drilldown for the dependencies that ServiceStack is referencing version 4.5 of the Code Pages.

I'm unsure of what I need to do to fix this...

servicestack
ormlite-servicestack
asked on Stack Overflow Feb 28, 2019 by SpaceCowboy74 • edited Feb 28, 2019 by SpaceCowboy74

1 Answer

1

If it's a .NET Core project then it should not be using any *.Core packages which after v5, are only meant for running ASP.NET Core Apps on the .NET Framework.

Since v5, the main packages, e.g: ServiceStack.OrmLite.SqlServer contain both .NET Standard 2.0 and .NET 4.5 Framework builds.

Given it's referencing the wrong packages I would uninstall all ServiceStack packages and only install the non .Core ServiceStack packages.

answered on Stack Overflow Feb 28, 2019 by mythz

User contributions licensed under CC BY-SA 3.0