1

从 v3.9.53 使用 NuGet 更新后,我收到此错误:

“无法加载文件或程序集 'ServiceStack.Text, Version=3.9.60.0, Culture=neutral, PublicKeyToken=null' 或其依赖项之一。系统找不到指定的文件。”:“ServiceStack.Text, Version=3.9 .60.0,文化=中性,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)
4

1 回答 1

4

I've run into this problem from time to time. Often it shows up when you have multiple projects in a solution that are targeting the same nuget assembly (such as ServiceStack.Text). One project will be updated but the old one will still contain an assembly reference to the wrong version. I've also seen it when using my own nuget packages that call out a ServiceStack dependency and then adding the dependency to another project within the same solution. I've hit this issue with SQLite more than anything else but I assume the same fixes apply:

1) Uninstalling and reinstalling dependencies through nuget (and removing references in Visual Studio). With ServiceStack.Text being a dependency of just about all the ServiceStack packages this could mean quite a bit of uninstalling and reinstalling.

2) You can add a bindingRedirect in my app.config. In this case we are saying "if you see ServiceStack.Text version 0.0.0.0 through 0.3.60.0 use version 3.9.63.0 instead". Keep in mind that this solution will work most of the time; however, if there was a major change between versions you could run into issues.

<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>
于 2013-10-01T04:34:45.053 回答