我继承了一个最初用.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的依赖项的钻取中看到了这一点。
我不知道该怎么做才能解决这个问题.
发布于 2019-02-28 16:43:41
如果它是一个.NET核心项目,那么它不应该使用任何在v5之后的*.Core包,这些包只用于运行基于ASP.NET框架的.NET核心应用程序。
由于v5,主包,例如:ServiceStack.OrmLite.SqlServer包含.NET标准2.0和.NET 4.5框架构建。
考虑到它引用了错误的包,我将卸载所有ServiceStack包,并且只安装非 .Core ServiceStack包。
https://stackoverflow.com/questions/54930216
复制相似问题