从 v3.9.53 开始使用 NuGet 更新后出现此错误:
"Could not load file or assembly 'ServiceStack.Text, Version=3.9.60.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"ServiceStack.Text, Version=3.9.60.0, Culture=neutral, PublicKeyToken=null"
问题是,NuGet 包安装了 v3.9.63.0,我以前从未安装过 3.9.60 版本。
我已经做了什么:
- 删除软件包并删除 Bin 文件,然后重新安装所有内容。
- 返回到我以前的版本 (v3.9.54),但我遇到了同样的错误。
有关错误的更多信息:
来源:ServiceStack.OrmLite
堆栈跟踪:
at ServiceStack.OrmLite.OrmLiteConfigExtensions.GetModelDefinition(Type modelType)
at ServiceStack.OrmLite.ModelDefinition`1.get_Definition()
at ServiceStack.OrmLite.OrmLiteUtilExtensions.ConvertToList[T](IDataReader dataReader)
at ServiceStack.OrmLite.OrmLiteReadExtensions.Select[T](IDbCommand dbCmd, String sqlFilter, Object[] filterParams)
at ServiceStack.OrmLite.OrmLiteReadConnectionExtensions.<>c__DisplayClass2`1.<Select>b__1(IDbCommand dbCmd)
at ServiceStack.OrmLite.ReadConnectionExtensions.Exec[T](IDbConnection dbConn, Func`2 filter)
at ServiceStack.OrmLite.OrmLiteReadConnectionExtensions.Select[T](IDbConnection dbConn, String sqlFilter, Object[] filterParams)
at DAL.UserCrud.GetAllUsers(Nullable`1& status)
最佳答案
我时常遇到这个问题。当您在一个解决方案中有多个项目针对同一个 nuget 程序集(例如 ServiceStack.Text)时,它通常会出现。将更新一个项目,但旧项目仍将包含对错误版本的程序集引用。我在使用我自己的 nuget 包调用 ServiceStack 依赖项然后将依赖项添加到同一解决方案中的另一个项目时也看到了它。我在 SQLite 中遇到的这个问题比其他任何问题都多,但我认为同样的修复适用:
1) 通过 nuget 卸载和重新安装依赖项(并删除 Visual Studio 中的引用)。由于 ServiceStack.Text 是几乎所有 ServiceStack 包的依赖项,这可能意味着需要大量卸载和重新安装。
2) 你可以添加一个bindingRedirect在我的 app.config 中。在这种情况下,我们说“如果您看到 ServiceStack.Text 版本 0.0.0.0 到 0.3.60.0,请改用版本 3.9.63.0”。请记住,此解决方案在大多数情况下都有效;但是,如果版本之间存在重大变化,您可能会遇到问题。
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ServiceStack.Text" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.9.60.0" newVersion="3.9.63.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
关于c# - OrmLite.SqlServer 程序集出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18998638/