升级的ServiceStack.OrmLite.SqlServer。现在获取有关System.Text.Encoding.CodePages的错误

问题描述 投票:2回答:1

我继承了一个最初用.NetCore 2.0编写的项目。我们使用的ServiceStack.OrmLite.SqlServer.Core的版本是1.0.43。我升级了NuGet中的所有东西,所以ServiceStack现在是5.4.0。

现在的问题是,当我尝试运行我的代码时:

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

我收到一个错误

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)

我在深入了解ServiceStack引用代码页4.5版的依赖项。

我不确定我需要做些什么来解决这个问题......

servicestack ormlite-servicestack
1个回答
1
投票

如果它是一个.NET Core项目,那么它不应该使用任何在v5之后的*.Core包,仅用于运行ASP.NET Core Apps on the .NET Framework

从v5开始,主包,例如:ServiceStack.OrmLite.SqlServer包含.NET Standard 2.0和.NET 4.5 Framework构建。

鉴于它引用了错误的软件包,我将卸载所有ServiceStack软件包并仅安装非.Core ServiceStack软件包。

© www.soinside.com 2019 - 2024. All rights reserved.