16
votes

I have to use a DLL as an API in my application (C#, .NET 4.5). I can reference the DLL normaly. No error at all. But if I want to use any class of this DLL, I get the following compile error:

Error CS1705 Assembly 'Assembly_X' with identity 'Assembly_X, Version=12.3.0.0, Culture=neutral, PublicKeyToken=c878e80841e75d00' uses 'Assembly_YY, Version=65535.65535.65535.65535, Culture=neutral, PublicKeyToken=c878e80841e75d00' which has a higher version than referenced assembly 'Assembly_YY' with identity 'Assembly_YY, Version=12.3.0.0, Culture=neutral, PublicKeyToken=c878e80841e75d00'

Then i checked the DLL (Assembly_X) in ILSpy. The Assembly_X has two references to Assembly_YY: One with the version 12.3.0.0 and one with the version 65535.65535.65535.65535.

I tried the "bindingRedirect" in the App.config. But since the error occures during compile time this doesn't help.

I don't have the source code of Assembly_X or Assembly_YY.

How can I use this DLL or repair it?


UPDATE

The developers of the dll finally answered my call for help. The only work around they know of is to use Visual Studio 2013 instead of Visual Studio 2015 or 2017. It seems VS 2013 is not bothered by these double reference at all.

They write, that the error is created by a encrypting tool for the dll. Thank you all for your ideas and help.

3
Can you update X and Y with the actual values? It will enable us to help you.mjwills
These are DLLs from another company and I cannot post the names of the DLLs. You will not know the DLLs, since only a few people in the world are working with them.Marius
since the PBK is the same, you could try and fake the version of your Assembly_YY by using ilmerge. Make sure you have a backup/copy of Assembly_YY before trying this. If that doesn't work you could try it the hard waySteffen Winkler
What version of the .NET Framework is the 3rd party DLL compiled against? Use assemblyinformation.codeplex.com or Telerik JustDecompile to quickly check. It might be incompatible with .net 4.5Andez
Good Idea. But it is the same Framwork Version. ILSpy gives me this information too [assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]Marius

3 Answers

3
votes

It looks like the first DLL is referencing a library which is a higher version than the other DLL you are using.

so you have 3 DLL's to consider: A, B & Bv2

Your project is referencing A & B But A references Bv2 (an updated version of B) SO when you go to use functions of A it throws an error because it finds B instead of Bv2.

2
votes

The problem basically that you are referencing 'Assembly_X' which references assemblies 'Assembly_YY' versions 12.3.0.0 and 65535.65535.65535.65535 and you referenced only 'Assembly_YY' version 12.3.0.0 in your application and didn't reference 65535.65535.65535.65535

Now according to the problem explanation on Microsoft Docs, and your example which you don't have the source code for the assemblies you have to:

Add a reference to 'Assembly_YY' version 65535.65535.65535.65535 of the DLL to your application to make it compile and to enable the application to run, you can provide an application configuration file that includes a <dependentAssembly> element that uses <assemblyIdentity> and <codeBase> child elements to specify the location of version 12.3.0.0 of the DLL.

0
votes

You are referencing a higher version of DLL then the one you currently have. You will need to add the reference to the higher version assembly:

'Assembly_YY, Version=65535.65535.65535.65535, Culture=neutral, PublicKeyToken=c878e80841e75d00' 

in order to solve this.

Right now you are referencing

 'Assembly_X' with identity 'Assembly_X, Version=12.3.0.0, Culture=neutral, PublicKeyToken=c878e80841e75d0

If this is a downloadable library, search for it in the nuget package manager and download it. If it's a library written by you, obtain the latest version of the library and add it to your project.