2

I have to use some dll files in my project that have a reference to assembly XXXXX. I now have newer version of this assembly in my project, however when I run my project I get error: Could not load file or assembly XXXXX, Version=XXXXX. I tried to resolve this problem using MSDN article Redirecting Assembly Versions. But it does not help. It seems that redirecting assembly does not work because I have different public token keys. It is null in old assembly. But it has some value "xxxxxxxxxxx" in newer assembly. How this problem could be resolved?

P.S. Similar question is here. But the difference is that I have different public token keys.

Community
  • 1
  • 1
Anton
  • 9,682
  • 11
  • 38
  • 68

2 Answers2

0

You will need to get a new version of the dll files you're using built against the new version of XXXXX.

You can learn more about assembly lookup in http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx.

fsimonazzi
  • 2,975
  • 15
  • 13
  • New versions of this dll with new reference is not available – Anton Nov 13 '12 at 16:34
  • 1
    Then you're out of luck. You might be able to build your own version of the assembly with the outdated reference to XXXXX referencing the new version using ildasm and ilasm as described in http://blogs.msdn.com/b/thottams/archive/2007/02/01/using-ilasm-and-ildasm.aspx. But this is a fairly low level task. I presume the assembly you'd need to rebuild is not signed, as it had a reference to an unsigned version of XXXXXX. – fsimonazzi Nov 13 '12 at 16:59
  • Can you have both versions of the XXXXX assembly, btw? – fsimonazzi Nov 13 '12 at 17:01
  • no, I can not have both versions... But your previous comment about ildasm helps me. I make dump from dll using ildasm. Then I changed references in il file and compile them using ilasm. So, I will mark your answer as correct. – Anton Nov 13 '12 at 17:31
0

The public key in the shared dll should protect apps from "man/dll-in-the-middle" attacks.

The dot net runtime correctly refuses to start main.exe with sub.dll when the current sub.dll has not the same public key it had when main.exe was compiled.

to solve this issue you can

  • recompile main.exe with the new sub.dll
  • make shure that both versions of sub.dll are compiled with the same public key. In your case you can remove the public key from sub.dll (i.e. using ilmerge ) because the old sub.dll had no key.
k3b
  • 14,517
  • 7
  • 53
  • 85
  • 1) I am not able to recompile and avoid from using 2 different references in dll files. There are 2 3rd party dll files that reference to different versions of some dll. 2)When I removed public key from sub.dll I get error: "Could not load file or assembly 'XXXXX' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)" – Anton Nov 13 '12 at 12:24