Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use .net DLL with broken References

Tags:

c#

.net

dll

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.

like image 519
Marius Avatar asked Aug 15 '17 12:08

Marius


People also ask

How do I fix broken references in Visual Studio?

To fix a broken project reference by correcting the reference path. In Solution Explorer, right-click your project node, and then select Properties. The Project Designer appears. If you're using Visual Basic, select the References page, and then click the Reference Paths button.

Can I use .NET framework DLL in .NET 6?

Yes, you can load . NET Framework assemblies into . NET Core 5 and 6.


1 Answers

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.

like image 105
Slipoch Avatar answered Sep 20 '22 18:09

Slipoch