Marius
Marius

Reputation: 369

Use .net DLL with broken References

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.

Upvotes: 16

Views: 1093

Answers (3)

Barr J
Barr J

Reputation: 10927

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.

Upvotes: 0

Slipoch
Slipoch

Reputation: 785

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.

Upvotes: 3

Tariq Abubaker
Tariq Abubaker

Reputation: 69

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.

Upvotes: 2

Related Questions