How to Reference Multiple Versions of Telerik.Documents

2 Answers 55 Views
General Discussions
Monique
Top achievements
Rank 1
Iron
Monique asked on 29 Mar 2023, 08:50 PM

I have an assembly called SharedUtllities.   It references an older version of Telerik.Documents.    I reference SharedUtllities  from JobsCore.   I also reference the lastes version of Telerik.Documents in JobsCore.   It compliles okay but, when I run it, I get a runtime error when the program hits  SharedUtllities ru = new SharedUtllities().   The error message is that it cannot find the older version of Telerik.Documents that I reference in SharedUtilities.

I cannot update the library versions used in SharedUtility  but I can recompile it.  I tried using Fody and tried using VS to include the old version in the exe but that didn’t work.    I tried to reference the old version as well as the new version got errors galore.    I also tried to use binding redirects.

So SharedUtilities references older version of Telerik.Documents.   The build does not copy any Telerik dlls.

JobsCore references SharedUtilites.dll.    Running JobsCore throws an error because it can’t find the old version of Telerik.Documents.

I can’t reference the old version and the current version.

 

 

 

Monique
Top achievements
Rank 1
Iron
commented on 29 Mar 2023, 09:13 PM

Here is the specific runtime error:

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'Telerik.Documents.Spreadsheet, Version=2022.2.428.20, Culture=neutral, PublicKeyToken=5803cfa389c90ce7'. The system cannot find the file specified.

2 Answers, 1 is accepted

Sort by
0
Accepted
Monique
Top achievements
Rank 1
Iron
answered on 31 Mar 2023, 02:08 PM

Here is the dependency structure in my C# Net Core project:    

Main Program  References SharedUtilities.dll  References Telerik.Documents.Spreadsheet.dll

Main and Shared must reference different versions of Telerik.Documents.Spreadsheet

 

Here is the solution that worked:

At the end of the first property group, add this to SharedUtilities project file:

    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

Install the Fody.Costura nuget package in the SharedUtilities project

Recompile

This solution embedded all dependent libraries into the DLL so I could distribute it without concern Telerik library versioning across my own DLLs.

 

Further, below is some useful information provided me by the excellent Telerik support team:

There are several approaches to dealing with dependency conflicts and one of them is indeed unifying the versions of all references. Another easier and more common approach is using Binding Redirects which forcefully tell the process which assembly to load in case of a conflict.

The following articles describe in detail and with examples how to utilize the Binding Redirects and also mention other alternative approaches to solving dependency conflicts:

0
Yoan
Telerik team
answered on 30 Mar 2023, 02:40 PM

Hi Monique,

For the project to work as expected, all the referenced assemblies must be the same version. This requirement does not originate from our implementation but rather is instilled by the framework. In that case, either the 'SharedUtllities' references must be updated to the latest version or the 'JobsCore' ones must be reverted to the older version.

Hope this helps.

Regards, Yoan Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Monique
Top achievements
Rank 1
Iron
Answers by
Monique
Top achievements
Rank 1
Iron
Yoan
Telerik team
Share this question
or