Nsubstitute: I just upgraded to Castle Core v4.2.0 and I am getting an assembly binding error

Created on 29 Sep 2017  路  3Comments  路  Source: nsubstitute/NSubstitute

I just upgraded Castle.Core from v4.1.1 to v4.2.0 and got an assembly binding error. Why is this happening?

Most helpful comment

This is because Castle Core changed the AssemblyVersion attribute to only include major version numbers only so that we can avoid assembly binding errors with future releases/upgrades of Castle Core.

Why is the assembly binding error happening then?

This is because NSubstitute have to release a version compiled against the new AssemblyVersion strategy, they are on it! :)

What do I do in the meantime? I want Castle Core bug fixes.

You can apply this following assembly binding redirect in your App.config.

 <dependentAssembly>
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.0.0.0" />
  </dependentAssembly>

Are you using Castle Core features directly?

If not and you are using the latest version of Visual Studio (15.3.5) then you should probably remove the NuGet reference altogether along with it's assembly bindings. This means Castle Core becomes a transitive dependency which you should not have to worry about.

Are you guys versioning properly at all?

Yes we are, we just use the AssemblyFileVersion instead.

image

I am still having issues.

Please post to this issue and we will try to help you.

All 3 comments

This is because Castle Core changed the AssemblyVersion attribute to only include major version numbers only so that we can avoid assembly binding errors with future releases/upgrades of Castle Core.

Why is the assembly binding error happening then?

This is because NSubstitute have to release a version compiled against the new AssemblyVersion strategy, they are on it! :)

What do I do in the meantime? I want Castle Core bug fixes.

You can apply this following assembly binding redirect in your App.config.

 <dependentAssembly>
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.0.0.0" />
  </dependentAssembly>

Are you using Castle Core features directly?

If not and you are using the latest version of Visual Studio (15.3.5) then you should probably remove the NuGet reference altogether along with it's assembly bindings. This means Castle Core becomes a transitive dependency which you should not have to worry about.

Are you guys versioning properly at all?

Yes we are, we just use the AssemblyFileVersion instead.

image

I am still having issues.

Please post to this issue and we will try to help you.

NSubstitute 3.0 released with Castle.Core 4.2.0 package reference.

Was this page helpful?
0 / 5 - 0 ratings