eliashdezr
eliashdezr

Reputation: 2115

Error with OrmLite.SqlServer Assembly

I'm getting this error after update with NuGet from v3.9.53:

"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"

The thing is, the NuGet Package installed the v3.9.63.0, I've never installed the 3.9.60 version before.

What I've already done:

More info about the error:

Source: ServiceStack.OrmLite

Stacktrace:

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)

Upvotes: 1

Views: 692

Answers (1)

Mike
Mike

Reputation: 1837

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>

Upvotes: 4

Related Questions