Could not load file or assembly ServiceStack.Inter

2019-07-26 23:20发布

问题:

I encountered the following error after upgrading to ServiceStack 5.0.2

Could not load file or assembly ServiceStack.Interfaces, Version=4.0.0.0, Culture=neutral, PublicKeyToken=e06fbc6124f57c43

Here are the references in my project file

<PackageReference Include="ServiceStack" Version="5.0.2" />
<PackageReference Include="ServiceStack.Api.Swagger" Version="5.0.2" />
<PackageReference Include="ServiceStack.Text" Version="5.0.2" />

Here are the reference seen from VS.

I dont have 'ServiceStack.Interfaces' reference in project file. So it is referenced indirectly somehow.

I dont know why it is trying to load an older version 4.0.0.0 when ServiceStack 5.0.2 is referenced.

So I intended to add bind rediction in app.config but then I found that is impossible.

In the binary folder, I do see ServiceStack.Interfaces.dll there. Its version is 5.0.0.0 but its PublicKeyToken is null. It does not allow redirecting the binding.

I tried to add a direct reference below but that does not solve my issue.

Why it is trying to load an older version?

回答1:

Delete your NuGet /packages folder and restore from NuGet again. You should only have ServiceStack v5.0.2 dependencies, if you have any other version you still have old package references that still need upgrading to v5.0.2.