Impossible to load two versions of the same libary in ASP.NET MVC

We’re using Telerik kendo library which allow us to use advanced UI widgets in our ASP.NET MVC project. Last week I was encouraged to upgrade the library, but we thought than we can have the same library linked twice trying to upgrade the library in some views and do the migration along the time.

But my attempt failed.

I registered two versions of the Telerik kendo library which assembly and library name is Kendo.Mvc in the csproj, to do this I renamed both libraries and I referenced in the project using the following code block. Furthermore I create aliases to reference each library version using ‘extern aliases’:

<Reference Include="Kendo.Mvc.2020, Version=2020.3.1021.545, Culture=neutral, PublicKeyToken=121FAE78165BA3D4">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..vendorKendo.Mvc.2020.dll</HintPath>
  <Aliases>Kendo_2020</Aliases>
  <Private>True</Private>
</Reference>
<Reference Include="Kendo.Mvc.2016, Version=2016.3.1118.545, Culture=neutral, PublicKeyToken=29AC1A93EC063D92">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..vendorKendo.Mvc.2016.dll</HintPath>
  <Aliases>Kendo_2016</Aliases>
  <Private>True</Private>
</Reference>

After that I change the codebase in the web.config to show where is the appropriate library version:

  <dependentAssembly>
    <assemblyIdentity name="Kendo.Mvc" publicKeyToken="29AC1A93EC063D92" culture="neutral" />   
    <bindingRedirect oldVersion="0.0.0.0-2016.3.1118.545" newVersion="2016.3.1118.545" />
    <codeBase version="2016.3.1118.545" href="Kendo.Mvc.2016.dll"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Kendo.Mvc" publicKeyToken="121FAE78165BA3D4" culture="neutral" />
    <bindingRedirect oldVersion="2016.3.1118.546-2020.3.1021.545" newVersion="2020.3.1021.545" />
    <codeBase version="2020.3.1021.545" href="Kendo.Mvc.2020.dll"/>
  </dependentAssembly>

Then I tried to use each version of the library using the extern links, like that:

extern alias Kendo_2016;
using Kendo_2016.Kendo.Mvc.Extensions;
using Kendo_2016.Kendo.Mvc.UI;
...

The bin folder has the two libraries:

Impossible to load two versions of the same libary in ASP.NET MVC

But when I launch the project, It shows an error that shows that it’s impossible to find a library:

Impossible to load two versions of the same libary in ASP.NET MVC

Why it can’t load the library if it’s in the right place?

Thank you!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Finally, after some researching hours I’ve got the answer In this post, and it works like a charm!.

The problem was that signed assemblies with a “Strong Name” secure it from some sort of modifications, between them, file renaming.

I was able to use ReflexIL to rename the assembly removing “Strong Name” and voila.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x