3
votes

I am trying to run protobuf-net v2 from my .net 4 project.

I took the dll from the .net3 directory and put in in my project but I now get:

Could not load file or assembly 'protobuf-net, Version=2.0.0.450, Culture=neutral, PublicKeyToken=257b51d87d2e4d67' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I tried adding this to my web.config:

  <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
    <bindingRedirect oldVersion="2.0.0.450" newVersion="4.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

but no go. Any tips?

1
That says: if something asks for 2.0.0.450, give them 4.0.0.0 instead, which is very-much not what you want. Can you clarify what the scenario is here, please? Happy to help (I'm the author), but I'm unclear... - Marc Gravell

1 Answers

1
votes

In most cases, there should be no need for any assembly-binding here at all. If you are getting errors with it not finding the previous version, then you might add a binding from 1.0.0.278 to 2.0.0.450 (for example; use the actual version numbers).

A binding to 4.0.0.0 is incorrect; you are already using the correct assembly. The only difference between the 2.0 dll and the 3.0 dll is some WCF-related APIs on the public interface. There is no specific 4.0 dll simply because 4.0 does not introduce any new API features that impact this library. Therefore, the dll from the net30 folder is absolutely fine for .net 4.0.

If you use the nuget package (starting from r452) it will automatically choose the appropriate dlls for your project.