Okay, I am a heavy user of Telerik's library of controls, specifically for ASP.NET. However, there is a small bit of functionality which I wanted to add to some of the controls. Nowadays I can do this easy enough using Extension methods. So I wrote a small library which does exactly that. Obviously, this library needs to reference their DLL (Telerik.Web.UI.dll
).
In the My Project > References
page of my DLL project, I have a reference to Telerik.Web.UI.dll
. For this reference, I have the Specific Version property set to False, because I don't want my library to care about what version of the Telerik DLL is being used. THIS is my problem though... the .NET compiler doesn't seem to honor this setting.
Case in point, I have a website which references both the Telerik DLL and mine. I updated the Telerik library to the latest version. Now when I try to run my website, I get:
Could not load file or assembly 'Telerik.Web.UI, Version=2012.1.215.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I fix this by going to my DLL project, recompiling it against the latest Telerik DLL, and then updating my DLL in the website. This is precisely what i didn't want to have to do every time I update Telerik's library. I thought that setting Specific Version to false would mean it would work with any version. No? Or am I completely misunderstanding what that setting does?
(That is, the project can reference a previously built version of the project.) So when should we use dll reference option? We need to use File reference or dll reference when the corresponding project or source code is not available in the solution.
The new version of the dll broke some specific functionality that had to be supported. The DLL name: wnvhtmltopdf.dll The old version: 14.2 The new version: 14.5 The solution has two parts:
If your referenced DLL version is higher than the version you included in the project (i.e. the opposite of this scenario) then by default Visual Studio will try to use the oldest version instead of the one you actually referenced!
The solution has two parts: Create a folder for the old DLL, let’s say wnv-old, and put it there. Add a reference to the old DLL. Every reference we add to the project will have the “global” alias by default.
You should look into using bindingRedirect
which will allow you to instruct .NET framework to use another version of assembly at runtime (i.e. if your project was compiled against version 1.0, it would still work with version 1.1, assuming there were no API changes).
Specific Version
attribute only applies to compile-time assembly reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With